Skip to content

fix(http): use @bodyRoot in HttpStream to eliminate spurious metadata-ignored warnings#10423

Open
n-sviridenko wants to merge 1 commit intomicrosoft:mainfrom
n-sviridenko:fix/http-stream-bodyroot
Open

fix(http): use @bodyRoot in HttpStream to eliminate spurious metadata-ignored warnings#10423
n-sviridenko wants to merge 1 commit intomicrosoft:mainfrom
n-sviridenko:fix/http-stream-bodyroot

Conversation

@n-sviridenko
Copy link
Copy Markdown

Thanks for creating such a lovely thing, that's something I was looking for for a while.

Problem

HttpStream defines @header contentType alongside @body body in the same model. This triggers the @typespec/http/metadata-ignored warning on every instantiation of HttpStream — including SSEStream from @typespec/sse:

node_modules/@typespec/http/lib/streams/main.tsp:22:11 - warning @typespec/http/metadata-ignored:
header property will be ignored as it is inside of a @body property. Use @bodyRoot instead if wanting to mix.
  occurred while instantiating template SSEStream<...>

This warning fires from library code that users cannot modify, making it impossible to use --warn-as-error without suppressing a warning they didn't cause.

Fix

Change @body body to @bodyRoot body in HttpStream. This is exactly what the warning message recommends, and it allows @header and body to coexist correctly.

Test plan

  • Existing HTTP stream tests pass
  • No @typespec/http/metadata-ignored warning when instantiating SSEStream

@Header contentType inside @Body is flagged by the metadata-ignored
linter rule. Switching to @bodyRoot allows mixing @Header and body
correctly, eliminating spurious warnings on every SSEStream instantiation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@n-sviridenko
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Apr 20, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@typespec/http@10423

commit: 37700b7

@github-actions
Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • @typespec/http
Show changes

@typespec/http - fix ✏️

Fix HttpStream to use @bodyRoot instead of @body so that the @header contentType property is not silently ignored, eliminating spurious @typespec/http/metadata-ignored warnings on every SSEStream instantiation.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@n-sviridenko can you show a repro of what you are seeing, I am not sure this is a correct fix.

Just using the stream as it is doesn't emit the warning. the content type header doesn't conflict as its not underneath that body. Do you have another header maybe inside the type, is that on purpose?

Image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants