fix(api): fail-closed json_schema.name charset and length - #654
fix(api): fail-closed json_schema.name charset and length#654cursor[bot] wants to merge 17 commits into
Conversation
…closed otherwise Chat history: message-level audio and legacy function_call are null/empty omit no-ops; non-empty fail closed with named errors (including tools passthrough). Tip substrate from #577 assistant refusal/annotations honesty. Local full unit: 940 passed.
…ed otherwise OpenAI fine-tune style message weight is not applied on this gateway. Accept null/0/1 as honest no-ops; reject other types and values with invalid_message_weight. Tip substrate from #578. Local full unit: 943 passed.
…ion role Reject unsupported message keys with named unknown_message_fields (not silent strip or tools-passthrough smuggle). Reject legacy function role with invalid_message_role migration to tool. Tip substrate from #579. Local full unit: 947 passed.
OpenAI partial-assistant prefix flag is not applied on this gateway. null/false are honest no-ops; true and non-booleans fail closed with invalid_message_prefix. Tip substrate from #580. Local full unit: 950 passed.
…therwise Named invalid_max_tool_calls on /v1/chat/completions instead of opaque unknown_fields. Aligns with Responses max_tool_calls honesty; gateway has no multi-step tool loop.
…losed otherwise Legacy /v1/completions treated max_tool_calls as unknown_fields. Accept the key for named invalid_max_tool_calls (null/empty/whitespace omit-equivalent), matching chat/Responses honesty so SDKs get a clear migration path.
SDK clients often send include_usage/include_obfuscation as JSON null. Drop null flag values before validation so null (and null+false mixes) match omit / all-false no-ops on chat, Completions, and Responses. True flags remain fail-closed with invalid_stream_options.
…or Responses parallel true SDK optional defaults often send function.strict and json_schema.strict as null — treat as omit rather than type errors. Align Responses parallel_tool_calls=true with chat by requiring a non-empty tools array.
SDK optional defaults often send description and parameters as JSON null. Treat null as omit rather than type errors; non-null non-string/object values remain fail-closed with invalid_tools.
OpenAI-style tool descriptions are at most 1024 characters. Over-long descriptions fail closed with named invalid_tools so SDKs never believe a truncated description was accepted.
SDK optional participant name blanks ("" / whitespace) are omit-equivalent
like JSON null. Non-string, over-long, and invalid charset names remain
fail-closed with invalid_message_name.
SDK optional defaults serialize omitted tool.function description/parameters/strict as JSON null. Accepting those keys without popping them is not omit-equivalent: proxy_completion forwards the body and several providers reject null parameters. Pop in place so passthrough matches omit; keep non-null wrong types on invalid_tools. Also pop response_format.json_schema.strict null. Tip substrate from #614. Local full unit: 989 passed.
…n keys SDK optional defaults serialize omitted response_format.json_schema description/strict as JSON null or blank. Leave those keys and the gateway forwards them; several providers reject strict: null. Pop in place so passthrough matches omit. Unknown inner keys and non-string descriptions stay invalid_response_format. HTTP echo tests cover chat and Responses. Docs cite OpenAI structured outputs and IETF JSON Schema 2020-12 in APA 7th. Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
SDK optional defaults serialize omitted function descriptions as empty or whitespace-only strings. Leaving those keys is not omit-equivalent: proxy_completion forwards them and several providers reject a blank description. Pop in place so passthrough matches omit; keep non-empty strings and fail-closed non-string values. Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
OpenAI Structured Outputs require response_format.json_schema.name to
match [a-zA-Z0-9_-]{1,64}, the same charset already enforced on
tool.function.name. Spaces, punctuation, and names longer than 64 were
forwarded and buyers saw an opaque provider rejection.
Fail closed with named invalid_response_format on chat and Responses.
HTTP echo tests keep a 64-character legal name. Docs cite the OpenAI
Structured Outputs name rule in APA 7th.
Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
Drive _validate_chat_response_format from exercise_request_body so
Hypothesis and Atheris share the omit-real + [a-zA-Z0-9_-]{1,64} name
invariants. Successful parses must keep a legal name and must not
forward null/blank description or non-bool strict.
Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
There was a problem hiding this comment.
Verdict: REQUEST_CHANGES on the unique tip (COMMENT event — cursor[bot] PRs reject REQUEST_CHANGES)
Reviewed b09aac3..133d70d only (a67264d charset + 133d70d fuzz). The 151-file honesty stack below b09aac3 is substrate. Do not merge this stack onto main. Do not APPROVE the unique commit until the ASCII charset is actually enforced.
Unique tip is not SOUND
_validate_chat_response_format documents OpenAI Structured Outputs [a-zA-Z0-9_-]{1,64} but implements str.isalnum(). Python isalnum() accepts Unicode letters and digits, so café, 名前, and Arabic-Indic ١٢٣ still pass the gateway. proxy_completion forwards them and the buyer still sees an opaque provider 400 — the honesty hole this tip claims to close.
The request-body fuzz invariant copies the same isalnum predicate, so Hypothesis will lock the Unicode accept in.
Buyer next action after the fix
Send response_format.json_schema.name that matches [a-zA-Z0-9_-]{1,64}. If the name uses spaces, punctuation, or non-ASCII letters/digits, expect 400 invalid_response_format from this gateway — fix the client payload, then retry. Do not wait for a provider 400.
Residual (not this landing)
Official Responses text.format remains invalid_text. Land that as its own unique tip after this ASCII check. Do not fold #639/#640 onto this tip.
Independent non-author APPROVE is still required after the ASCII check and Unicode HTTP cases land.
Sent by Cursor Automation: Fix Issues
| "invalid_response_format", | ||
| "response_format.json_schema.name must be at most 64 characters", | ||
| ) | ||
| if not all(ch.isalnum() or ch in "_-" for ch in name): |
There was a problem hiding this comment.
str.isalnum() is not [a-zA-Z0-9_-]. café, 名前, and ١٢٣ all pass this predicate and fail re.fullmatch(r"[a-zA-Z0-9_-]{1,64}", name).
That is the buyer hole this tip claims to close: the gateway forwards the name and the provider returns an opaque 400 instead of invalid_response_format.
Require ASCII before isalnum, or re.fullmatch(r"[a-zA-Z0-9_-]{1,64}", name). Keep the named invalid_response_format next action. Do not expand this landing to rewrite substrate tool.function.name call sites.
| assert isinstance(schema, dict) | ||
| name = schema.get("name") | ||
| assert isinstance(name, str) and 1 <= len(name) <= 64 | ||
| assert all(ch.isalnum() or ch in "_-" for ch in name) |
There was a problem hiding this comment.
This invariant copies the Unicode-accepting isalnum rule. After the validator is ASCII-strict, this assert must match [a-zA-Z0-9_-]{1,64} or Hypothesis will treat a Unicode accept as success and hide the regression.
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
Pull request was closed
|
Superseded by tip substrate ≥ #691 (cumulative OpenAI/gateway honesty band + auto-merge tip). Closing to free product-gate runners (Full unit + Semgrep). |


Summary
response_format.json_schema.nameto match[a-zA-Z0-9_-]{1,64}— the same charset already enforced ontool.function.name.invalid_response_formaton/v1/chat/completionsand/v1/responses.echo.response_format.a67264don the fix(api): pop null json_schema description/strict omit-real before proxy #646 omit-real substrate. Do not merge this stack ontomain. Land the unique commit after Full unit + Semgrep.Test plan
python3 tests/test_json_schema_name_charset_http_honesty.py(ok)python3 tests/test_json_schema_inner_fields_omit_http_honesty.py(ok)python3 tests/test_chat_response_format_http_honesty.py(ok)python3 tests/test_responses_response_format_http_honesty.py(ok)Reviewer next action
Review the unique tip (
a67264d) only. Do not APPROVE the 151-file honesty stack as amainmerge. Independent non-author APPROVE is still required for the unique commit.