Skip to content

Fix false-positive JSONL content type matches#277

Open
fallintoplace wants to merge 1 commit into
openai:mainfrom
fallintoplace:fix/jsonl-content-type-regex
Open

Fix false-positive JSONL content type matches#277
fallintoplace wants to merge 1 commit into
openai:mainfrom
fallintoplace:fix/jsonl-content-type-regex

Conversation

@fallintoplace

@fallintoplace fallintoplace commented May 19, 2026

Copy link
Copy Markdown

Summary

  • require JSONL content types to use a recognized application/ subtype and stop at the subtype boundary
  • preserve valid x-ndjson, x-ldjson, jsonl, and x-jsonl matches, including parameters, optional whitespace, and mixed casing
  • add regression coverage for unrelated values that previously matched, plus subtype suffixes such as application/jsonlines

Why

decode_content uses this matcher to select line-delimited JSON parsing. The previous regex could therefore send unrelated response bodies through the JSONL decoder and raise parser errors or return the wrong decoded shape.

Fixes #276.

Test plan

  • bundle exec rake TEST=test/openai/internal/util_test.rb test
  • bundle exec rake lint

@fallintoplace fallintoplace marked this pull request as ready for review May 19, 2026 17:41
@fallintoplace fallintoplace requested a review from a team as a code owner May 19, 2026 17:41
@jbeckwith-oai jbeckwith-oai added the generator Touches generated SDK files label Jul 16, 2026
@fallintoplace fallintoplace force-pushed the fix/jsonl-content-type-regex branch from d89ace1 to 4f5db1e Compare July 16, 2026 23:29
@fallintoplace fallintoplace changed the title Tighten JSONL content type matching Fix false-positive JSONL content type matches Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

generator Touches generated SDK files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSONL content type matcher accepts unrelated strings

2 participants