Skip to content

fix(responses): recognize exact case-insensitive media types - #7768

Merged
lidge-jun merged 14 commits into
devfrom
fix/responses-exact-media-types-20261026
Oct 28, 2026
Merged

lidge-jun merged 14 commits into
devfrom
fix/responses-exact-media-types-20261026

Conversation

@luvs01

@luvs01 luvs01 commented Oct 26, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Internal Responses consumers can mistake a valid Text/Event-Stream response for JSON, or treat an unrelated media type as SSE when a parameter merely mentions text/event-stream. Use one exact, case-insensitive type/subtype comparison before choosing the decoder.

Apply it to JEV decisions, routed compaction, recovery, combo/native stream preflight, native delivery, and the buffered required-tool JSON guard. Preserve the existing missing-header behavior and leave explicitly unrelated bodies unread. Update the owning contracts and regression coverage; HTTP-only V2 fixtures now reject accidental WebSocket construction.

Verification

Current head: 9d02241, a normal merge of dev 9e48f78. All seven PR product-file blobs are unchanged from c4b58b2.

  • The merged candidate passed 10 media-type behavior cases, 29 layout/tooling cases, source typecheck, structure, size ratchet, privacy and whitespace checks on Windows/Bun 1.4.4.
  • The layout gate caught missing dev registrations in the first merge candidate. The final root-plus-shards mapping preserves every dev and PR entry with no duplicates or changed assignments; the corrected layout gate passed. The unchanged product suites were not repeated after this registration-only correction.
  • Validation used bounded commands with native exit, EOF and owned-process cleanup checks. Candidate source/index hashes remained stable; no owned process or fixture remained.
  • Earlier implementation evidence at a15c744 includes RED 2 pass/8 fail before the native-delivery correction, then 10/10 pass, plus a 44-case focused changed run. Hosted logs also confirm the 34 HTTP plaintext-V2 cases passed. These are historical scopes, not a new full-suite result.
  • The prior c4b58b2 head passed automatic CI and Catalog async contracts. The current 9d02241 head also passed Cross-platform CI and Catalog async contracts.

An earlier broad local run reached its 180-second bound at 2,312 passes/3 failures: two quota-fixture failures reproduced on the unchanged base; one sidecar timeout remained unexplained. No full local repository pass or native macOS acceptance is claimed. Native jobs skipped by PR selection are not platform coverage.

The change is ready for maintainer review. Explicit security review remains required before merge.

Checklist

  • Scope stays focused and avoids unrelated cleanup.
  • Docs or release notes were updated when needed.
  • Security-sensitive changes were reviewed for secrets, auth, and unsafe defaults.

Co-authored-by: Epinephrine luvs01@hanmail.net

Summary by CodeRabbit

  • Bug Fixes

    • Improved response handling so valid event-stream and JSON media types are recognized consistently regardless of capitalization or parameters.
    • Prevented unrelated content types from being mistaken for event streams or JSON.
    • Preserved existing handling for missing content types and plaintext V2 responses.
  • Documentation

    • Clarified how response media types affect routing, parsing, and passthrough behavior.
  • Tests

    • Added coverage for varied content-type formats across response delivery, routing, and recovery.

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 801dd4f and 4d4695b.

Files selected for processing: 1
  • tests/fixtures/test-layout-expected.json

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

Walkthrough

Response handling now uses exact media-type matching that ignores case and parameters. Event-stream and JSON consumers use the shared matcher. Tests cover valid media-type variants, unrelated types, passthrough behavior, and existing fallback behavior.

Changes: Response media-type matching

Layer / File(s) Summary
Shared media-type classification
src/lib/http-response-semantics.ts, src/server/responses/*, docs-site/src/content/docs/reference/adapters.md, structure/providers/jev-decision.md, structure/transports/*
hasResponseMediaType matches the trimmed type/subtype before parameters and ignores case. Response consumers use it to classify event-stream and JSON responses. Existing missing-content-type fallbacks and plaintext V2 event validation remain.
Media-type regression coverage
tests/responses/*, tests/routing/combo-stream-preflight.test.ts, tests/server/*, tests/fixtures/test-layout-expected.json, scripts/test-layout/layout*.json
Tests cover case variations, parameters, unrelated media types, body consumption, passthrough behavior, decision routing, and compaction recovery. Test layout configuration adds the media-type test and moves passthrough mappings to the response layout.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Possibly related PRs

  • lidge-jun/opencodex#7741: Adds the buffered native Responses required-tool guard that this change updates to use exact JSON media-type matching.
Merge Risk: Minimal · previous review 4d469

No actionable current-head risk is identified in this change.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: response handling now recognizes exact media types without case sensitivity. It matches the changes across response routing, decoding, prefli…
Docstring Coverage Passed Docstring coverage is inconclusive: files from earlier reviews still need to be rechecked within the check's analysis limits. Not blocking.
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.
Full details: Title check

Explanation

The title clearly and concisely describes the main change: response handling now recognizes exact media types without case sensitivity. It matches the changes across response routing, decoding, preflight checks, and tests.

Finishing Touches
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions github-actions Bot added the bug Something isn't working label Oct 26, 2026
@github-actions

github-actions Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

✅ Deterministic PR hygiene checks passed.

@luvs01
luvs01 marked this pull request as ready for review October 26, 2026 15:58
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-10-26T16:01:26.172657Z a15c744 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

# Conflicts:
#	tests/fixtures/test-layout-expected.json
# Conflicts:
#	scripts/test-layout/layout.json
# Conflicts:
#	tests/fixtures/test-layout-expected.json
# Conflicts:
#	structure/transports/responses-combo-boundaries.md
# Conflicts:
#	scripts/test-layout/layout.json
@lidge-jun

Copy link
Copy Markdown
Owner

Maintainer integration into dev (MAINTAINERS.md maintainer-integration path).

  • Head: 302c0782c211dffb6f756aec8e0b905b51976a3a
  • Review: reviewed in L8 (luvs01 review task); later commits are origin/dev merges, the last conflict-bearing one (0c7fe438b, structure doc) verified locally 392/0 and the head re-verified 325/0 with typecheck, structure:check and privacy:scan.
  • PR CI: Cross-platform CI run 40607004534 succeeded on this head; required checks green.
  • Scratch merge with current dev (504417f0ef): clean, file-size ratchet 0 offenders.
  • Dev batch gate: lane=all run 40617484699 on f7b4fd6c; its only failure (windows 8/9, bearer-admission-routed-provider 30 s timeout) is a pre-existing flake tracked separately.

@lidge-jun
lidge-jun merged commit 0eb5897 into dev Oct 28, 2026
30 of 54 checks passed
@lidge-jun
lidge-jun deleted the fix/responses-exact-media-types-20261026 branch October 28, 2026 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants