Repository navigation
fix(http-client-js): allow none encoding on bytes without unknown-encoding diagnostic - #12371
Akash Sarangi (Roxen-AS) wants to merge 4 commits into
Conversation
…oding diagnostic (microsoft#12356) Signed-off-by: Roxen-AS <akash.arjun12@gmail.com>
|
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. |
There was a problem hiding this comment.
🟡 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>
…body transform Signed-off-by: Roxen-AS <akash.arjun12@gmail.com>
commit: |
|
All changed packages have been documented.
Show changes
|
Jeff Fisher (xirzec)
left a comment
There was a problem hiding this comment.
Overall, a good change, but I'd appreciate the commented cleanups before merging.
| `; | ||
| const [outputs, diagnostics] = await emitWithDiagnostics(code); | ||
| expect(diagnostics.length).toBeGreaterThan(0); | ||
| expect(diagnostics.some((d) => d.code === "@typespec/http-client-js/unknown-encoding")).toBe(true); |
There was a problem hiding this comment.
please follow the repo convention to use expectDiagnostics instead of rolling your own, e.g.
| expect(diagnostics.some((d) => d.code === "@typespec/http-client-js/unknown-encoding")).toBe(true); | |
| expectDiagnostics(diagnostics, [ | |
| { code: "@typespec/http-client-js/unknown-encoding", severity: "warning" }, | |
| { code: "@typespec/http-client-js/unknown-encoding", severity: "warning" }, | |
| ]); |
There was a problem hiding this comment.
Updated to use \expectDiagnostics\ per convention in commit 029981e. Thanks!
| `; | ||
| const [outputs, diagnostics] = await emitWithDiagnostics(code); | ||
| expect(diagnostics.length).toBeGreaterThan(0); | ||
| expect(diagnostics.some((d) => d.code === "@typespec/http-client-js/unknown-encoding")).toBe(true); |
There was a problem hiding this comment.
same as above
| expect(diagnostics.some((d) => d.code === "@typespec/http-client-js/unknown-encoding")).toBe(true); | |
| expectDiagnostics(diagnostics, { | |
| code: "@typespec/http-client-js/unknown-encoding", | |
| severity: "warning", | |
| }); |
There was a problem hiding this comment.
Updated to use \expectDiagnostics\ in commit 029981e. Thanks!
| @body body: bytes, | ||
| ): void; | ||
| `; | ||
| const [outputs, diagnostics] = await emitWithDiagnostics(code); |
There was a problem hiding this comment.
you can reuse the emit helper from test-host.ts for this
There was a problem hiding this comment.
Updated both clean request and response tests to reuse the \emit\ helper in commit 029981e. Thanks!
…w feedback Signed-off-by: Roxen-AS <akash.arjun12@gmail.com>


Fixes #12356
Description
When a
bytesbody is used with a binary content type (such asapplication/octet-stream), the compiler sets the default byte encoding to"none". However,@typespec/http-client-js'sscalar-transform.tsxonly explicitly handled"base64"and"base64url", falling through to emit anunknown-encodingwarning for"none".This PR:
case "none": return passthroughTransformer(itemRef);in bothtoTransportandtoApplicationbyte transforms inscalar-transform.tsx.bytesbody and binary content type emits cleanly without anyunknown-encodingdiagnostics.