Skip to content

Support HttpApiSchema.StreamUint8Array request payloads in HttpApiClient - #6505

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

Support HttpApiSchema.StreamUint8Array request payloads in HttpApiClient#6505
leonitousconforti wants to merge 2 commits 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 to be transmitted as streamed binary data (not JSON).
    • Preserved the declared content type for streamed request bodies across endpoints.
  • Tests
    • Added coverage ensuring streamed payloads are sent correctly, including chunked data content and content-type handling.
  • Documentation
    • Documented the streaming request payload fix and its impact on request encoding.

@changeset-bot

changeset-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: e3a60c1

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

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 96b350d0-b367-42d6-9146-f98876aeb4e5

📥 Commits

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

📒 Files selected for processing (2)
  • packages/effect/src/unstable/httpapi/HttpApiClient.ts
  • packages/effect/test/unstable/httpapi/HttpApiClient.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/effect/test/unstable/httpapi/HttpApiClient.test.ts

📝 Walkthrough

Walkthrough

This change preserves StreamUint8Array payload schemas during endpoint construction and encodes them as streamed HttpBody request bodies using the schema content type. Tests verify streamed chunks and endpoint-specific content types.

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 upload endpoints define streamed request contracts with default and custom content types.
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 types and concatenated chunks, and the changeset documents the fix.

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

Suggested labels: enhancement

Suggested reviewers: gcanti, imax153

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
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 thread packages/effect/src/unstable/httpapi/HttpApiClient.ts
@tim-smart tim-smart added the 4.0 label Jul 20, 2026
@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
basic.ts 6.63 KB 6.63 KB 0.00 KB (0.00%)
batching.ts 9.42 KB 9.42 KB 0.00 KB (0.00%)
brand.ts 6.29 KB 6.31 KB -0.02 KB (-0.30%)
cache.ts 10.12 KB 10.12 KB 0.00 KB (0.00%)
config.ts 19.77 KB 20.04 KB -0.27 KB (-1.35%)
differ.ts 18.96 KB 19.93 KB -0.97 KB (-4.87%)
http-client.ts 20.94 KB 20.97 KB -0.03 KB (-0.15%)
logger.ts 10.28 KB 10.28 KB 0.00 KB (0.00%)
metric.ts 8.55 KB 8.55 KB 0.00 KB (0.00%)
optic.ts 7.45 KB 7.33 KB +0.12 KB (+1.64%)
pubsub.ts 14.26 KB 14.26 KB 0.00 KB (0.00%)
queue.ts 11.09 KB 11.09 KB 0.00 KB (0.00%)
schedule.ts 10.27 KB 10.27 KB 0.00 KB (0.00%)
schema-class.ts 18.72 KB 18.86 KB -0.15 KB (-0.77%)
schema-fromJsonSchemaDocument.ts 28.69 KB 28.67 KB +0.02 KB (+0.07%)
schema-representation-roundtrip.ts 24.98 KB 24.99 KB -0.01 KB (-0.03%)
schema-string-transformation.ts 12.96 KB 12.95 KB +0.01 KB (+0.10%)
schema-string.ts 10.65 KB 10.65 KB 0.00 KB (0.00%)
schema-template-literal.ts 14.85 KB 14.85 KB 0.00 KB (0.00%)
schema-toArbitraryLazy.ts 21.52 KB 21.66 KB -0.13 KB (-0.62%)
schema-toCodeDocument.ts 24.00 KB 24.08 KB -0.07 KB (-0.30%)
schema-toCodecJson.ts 18.87 KB 18.91 KB -0.04 KB (-0.21%)
schema-toEquivalence.ts 18.59 KB 18.73 KB -0.14 KB (-0.75%)
schema-toFormatter.ts 18.45 KB 18.59 KB -0.14 KB (-0.75%)
schema-toJsonSchemaDocument.ts 22.08 KB 22.33 KB -0.25 KB (-1.12%)
schema-toRepresentation.ts 19.13 KB 19.25 KB -0.12 KB (-0.61%)
schema.ts 18.00 KB 18.12 KB -0.12 KB (-0.68%)
stm.ts 12.05 KB 12.05 KB 0.00 KB (0.00%)
stream.ts 9.37 KB 9.37 KB 0.00 KB (0.00%)

StreamUint8Array schemas all share a single AST while carrying their
content type on the schema object, so caching encoders by AST let the
first stream endpoint's content type leak into every other stream
endpoint.
@coderabbitai coderabbitai Bot added enhancement New feature or request and removed bug Something isn't working labels Jul 28, 2026
@effect-slopcop effect-slopcop Bot added the bug Something isn't working label Jul 28, 2026
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 enhancement New feature or request ready for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants