Skip to content

Support HttpApiSchema.StreamUint8Array request payloads in HttpApiClient#6505

Open
leonitousconforti wants to merge 1 commit into
Effect-TS:mainfrom
leonitousconforti:fix/httpapi-stream-request-payloads
Open

Support HttpApiSchema.StreamUint8Array request payloads in HttpApiClient#6505
leonitousconforti wants to merge 1 commit into
Effect-TS:mainfrom
leonitousconforti:fix/httpapi-stream-request-payloads

Conversation

@leonitousconforti

@leonitousconforti leonitousconforti commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Type

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Related

  • Related Issue #
  • Closes #

Summary by CodeRabbit

  • Bug Fixes

    • Fixed HTTP API streaming request payloads so they are sent as streamed binary data instead of being incorrectly encoded as JSON.
    • Preserved the configured content type for streamed request bodies.
  • Tests

    • Added coverage verifying streamed payloads, content types, and transmitted data.
  • Documentation

    • Documented the streaming request payload fix.

@github-project-automation github-project-automation Bot moved this to Discussion Ongoing in PR Backlog Jul 20, 2026
@changeset-bot

changeset-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f3eccc3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 27 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This change preserves StreamUint8Array payload schemas during endpoint construction and encodes them as streamed HttpBody request bodies with the schema content type. Tests verify streamed chunks and application/octet-stream content.

Changes

Streaming request payloads

Layer / File(s) Summary
Preserve stream payload schema
packages/effect/src/unstable/httpapi/HttpApiEndpoint.ts, packages/effect/test/unstable/httpapi/HttpApiClient.test.ts
Stream schemas bypass payload transformation, and UploadApi defines a streamed upload endpoint.
Encode and validate streamed HTTP bodies
packages/effect/src/unstable/httpapi/HttpApiClient.ts, packages/effect/test/unstable/httpapi/HttpApiClient.test.ts, .changeset/httpapi-client-stream-request-payloads.md
HttpApiClient encodes stream payloads with HttpBody.stream; tests verify content type and concatenated chunks, and the changeset documents the fix.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels: bug

Suggested reviewers: gcanti, imax153

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically matches the main change: adding HttpApiSchema.StreamUint8Array request payload support in HttpApiClient.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot added the bug Something isn't working label Jul 20, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/effect/src/unstable/httpapi/HttpApiClient.ts`:
- Around line 1003-1016: Update the stream-schema handling around
HttpApiSchema.isStreamUint8Array so StreamUint8Array and StreamSse encoders are
not cached or retrieved by shared AST identity. Key bodyFromPayloadCache by the
schema object for stream schemas, or bypass that cache for them, ensuring each
schema preserves its own contentType and mode; add a regression test covering
distinct custom content types.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2cbb97b2-3731-4daf-b828-316c164acc27

📥 Commits

Reviewing files that changed from the base of the PR and between c1288dd and f3eccc3.

📒 Files selected for processing (4)
  • .changeset/httpapi-client-stream-request-payloads.md
  • packages/effect/src/unstable/httpapi/HttpApiClient.ts
  • packages/effect/src/unstable/httpapi/HttpApiEndpoint.ts
  • packages/effect/test/unstable/httpapi/HttpApiClient.test.ts

Comment on lines +1003 to +1016
if (HttpApiSchema.isStreamUint8Array(schema)) {
const out = $HttpBody.pipe(Schema.decodeTo(
schema,
SchemaTransformation.transformOrFail<Stream.Stream<Uint8Array, unknown>, HttpBody.HttpBody>({
decode(httpBody) {
return Effect.fail(new SchemaIssue.Forbidden(Option.some(httpBody), { message: "Encode only schema" }))
},
encode(stream) {
return Effect.succeed(HttpBody.stream(stream, schema.contentType))
}
})
))
bodyFromPayloadCache.set(ast, out)
return out

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

Do not cache stream encoders by the shared AST.

StreamUint8Array and StreamSse instances share streamSchema.ast, but their contentType and mode live on the schema object. Because the AST cache is checked before this branch, the first stream schema can determine the encoder for later requests, causing custom content types to be silently wrong or bypassing this branch entirely.

Use a cache keyed by schema identity, or skip bodyFromPayloadCache for stream schemas. Add a regression test with a custom content type.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/effect/src/unstable/httpapi/HttpApiClient.ts` around lines 1003 -
1016, Update the stream-schema handling around HttpApiSchema.isStreamUint8Array
so StreamUint8Array and StreamSse encoders are not cached or retrieved by shared
AST identity. Key bodyFromPayloadCache by the schema object for stream schemas,
or bypass that cache for them, ensuring each schema preserves its own
contentType and mode; add a regression test covering distinct custom content
types.

@github-project-automation github-project-automation Bot moved this from Discussion Ongoing to Waiting on Author in PR Backlog Jul 20, 2026
@tim-smart tim-smart added the 4.0 label Jul 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

File Name Current Size Previous Size Difference
basic.ts 6.66 KB 6.66 KB 0.00 KB (0.00%)
batching.ts 9.27 KB 9.27 KB 0.00 KB (0.00%)
brand.ts 6.14 KB 6.14 KB 0.00 KB (0.00%)
cache.ts 10.13 KB 10.13 KB 0.00 KB (0.00%)
config.ts 18.89 KB 18.89 KB 0.00 KB (0.00%)
differ.ts 17.10 KB 17.10 KB 0.00 KB (0.00%)
http-client.ts 20.58 KB 20.58 KB 0.00 KB (0.00%)
logger.ts 10.26 KB 10.26 KB 0.00 KB (0.00%)
metric.ts 8.52 KB 8.52 KB 0.00 KB (0.00%)
optic.ts 7.35 KB 7.35 KB 0.00 KB (0.00%)
pubsub.ts 14.10 KB 14.10 KB 0.00 KB (0.00%)
queue.ts 11.09 KB 11.09 KB 0.00 KB (0.00%)
schedule.ts 10.30 KB 10.30 KB 0.00 KB (0.00%)
schema-class.ts 17.96 KB 17.96 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 4.06 KB 4.06 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 27.33 KB 27.33 KB 0.00 KB (0.00%)
schema-string-transformation.ts 12.62 KB 12.62 KB 0.00 KB (0.00%)
schema-string.ts 10.30 KB 10.30 KB 0.00 KB (0.00%)
schema-template-literal.ts 14.27 KB 14.27 KB 0.00 KB (0.00%)
schema-toArbitraryLazy.ts 20.73 KB 20.73 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 21.32 KB 21.32 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 17.93 KB 17.93 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 17.82 KB 17.82 KB 0.00 KB (0.00%)
schema-toFormatter.ts 17.65 KB 17.65 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 20.21 KB 20.21 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 18.20 KB 18.20 KB 0.00 KB (0.00%)
schema.ts 17.23 KB 17.23 KB 0.00 KB (0.00%)
stm.ts 12.02 KB 12.02 KB 0.00 KB (0.00%)
stream.ts 9.30 KB 9.30 KB 0.00 KB (0.00%)

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

Labels

4.0 bug Something isn't working

Projects

Status: Waiting on Author

Development

Successfully merging this pull request may close these issues.

2 participants