Skip to content

fix(http-client-js): allow none encoding on bytes without unknown-encoding diagnostic - #12371

Open
Akash Sarangi (Roxen-AS) wants to merge 5 commits into
microsoft:mainfrom
Roxen-AS:fix/http-client-js-bytes-none-encoding-12356
Open

Akash Sarangi (Roxen-AS) wants to merge 5 commits into
microsoft:mainfrom
Roxen-AS:fix/http-client-js-bytes-none-encoding-12356

Conversation

@Roxen-AS

Copy link
Copy Markdown
Contributor

Fixes #12356

Description

When a bytes body is used with a binary content type (such as application/octet-stream), the compiler sets the default byte encoding to "none". However, @typespec/http-client-js's scalar-transform.tsx only explicitly handled "base64" and "base64url", falling through to emit an unknown-encoding warning for "none".

This PR:

  1. Handles case "none": return passthroughTransformer(itemRef); in both toTransport and toApplication byte transforms in scalar-transform.tsx.
  2. Adds unit test coverage verifying that an operation with a bytes body and binary content type emits cleanly without any unknown-encoding diagnostics.
  3. Adds a Chronus changelog entry.

…oding diagnostic (microsoft#12356)

Signed-off-by: Roxen-AS <akash.arjun12@gmail.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The unsupported-encoding test does not trigger its expected diagnostic, and response-side warning regression coverage is missing.

2 open issues
What changed in this PR

Fixes #12356 by treating "none" as a supported byte encoding in the JavaScript HTTP client emitter, avoiding warnings for raw binary bodies.

Changes:

  • Adds passthrough handling for byte serialization and deserialization.
  • Adds tests for binary-body diagnostics and unsupported encodings.
  • Adds a Chronus fix entry.
File Description
packages/​http-client-js/​test/​bytes-none-encoding.test.ts Adds encoding diagnostic tests.
packages/​http-client-js/​src/​components/​transforms/​scalar-transform.tsx Handles "none" encoding in both transform directions.
.chronus/​changes/​fix-http-client-js-bytes-none-encoding.md Documents the warning fix.

Review effort: Balanced

…lar for unsupported encoding

Signed-off-by: Roxen-AS <akash.arjun12@gmail.com>
Copilot AI balanced review requested due to automatic review settings October 23, 2026 02:36

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused change preserves byte handling and covers both transformation directions, with no unresolved blocking issues from static review; tests were not executed.

1 open issue
1 resolved since last review

Review effort: Balanced

…body transform

Signed-off-by: Roxen-AS <akash.arjun12@gmail.com>
Copilot AI balanced review requested due to automatic review settings October 23, 2026 02:58

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The narrow fix preserves byte passthrough behavior, covers both affected directions, and has no identified blocking issues.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

@pkg-pr-new

pkg-pr-new Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/microsoft/typespec/@typespec/http-client-js@12371

commit: d59d4d3

@github-actions

Copy link
Copy Markdown
Contributor

All changed packages have been documented.

  • ✅ @typespec/http-client-js
Show changes

@typespec/http-client-js - fix ✏️

Prevent reporting spurious unknown-encoding warnings for raw bytes body with none encoding (e.g. binary content types such as application/octet-stream).

@xirzec Jeff Fisher (xirzec) left a comment

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.

Overall, a good change, but I'd appreciate the commented cleanups before merging.

…w feedback

Signed-off-by: Roxen-AS <akash.arjun12@gmail.com>
Copilot AI balanced review requested due to automatic review settings October 24, 2026 05:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused fix preserves byte passthrough behavior, covers both transformation directions, and retains warnings for unsupported encodings.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 30, 2026 20:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues are reported for the change supporting raw bytes with "none" encoding.

No open issues 🎉

Review effort: Balanced

This branch has not been deployed

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

Labels

emitter:client:js Issue for the JS client emitter: @typespec/http-client-js

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: http-client-js reports unknown-encoding for a raw bytes body

4 participants