Skip to content

fix(api): require ASCII for json_schema.name charset - #669

Closed
seonghobae wants to merge 18 commits into
mainfrom
cursor/bc-64fcb7ec-51b8-420c-b1e7-cb08a553a56d-0837
Closed

fix(api): require ASCII for json_schema.name charset#669
seonghobae wants to merge 18 commits into
mainfrom
cursor/bc-64fcb7ec-51b8-420c-b1e7-cb08a553a56d-0837

Conversation

@seonghobae

Copy link
Copy Markdown
Contributor

Summary

  • fix(api): fail-closed json_schema.name charset and length #654 documented OpenAI Structured Outputs [a-zA-Z0-9_-]{1,64} but implemented str.isalnum(), which accepts Unicode letters and digits (café, Japanese schema names, Arabic-Indic digits).
  • Those names were still forwarded; buyers saw an opaque provider rejection instead of named invalid_response_format.
  • Require name.isascii() before alnum/_/- on /v1/chat/completions and /v1/responses.
  • HTTP honesty: Unicode reject on both surfaces; Responses keeps a 64-character legal name on mock echo.response_format.
  • Fuzz invariant now matches the ASCII regex.
  • Unique tip 8251149 on the fix(api): fail-closed json_schema.name charset and length #654 substrate. Do not merge this stack onto main. Land the unique commit after Full unit + Semgrep.
  • Next unique tip after this: official Responses text.format (currently invalid_text). Do not fold that onto this tip.

Test plan

  • python3 tests/test_json_schema_name_charset_http_honesty.py (ok; RED on Unicode name before the isascii() guard)
  • inner-omit / chat / Responses response_format honesty (ok)
  • paper / API / product-planning / conventions / self-check (ok)
  • exercise_request_body Unicode + ASCII name cases (ok)
  • CI Full unit + Semgrep

Reviewer next action

Review the unique tip (8251149) only. Confirm Unicode names return 400 invalid_response_format and that a 64-character ASCII name still echoes. Do not APPROVE the honesty stack as a main merge.

Buyer next action

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 — rename the schema to the ASCII charset, then retry.

Papers (APA 7th)

seonghobae and others added 18 commits August 16, 2026 21:18
…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>
str.isalnum() accepted Unicode letters and digits (café, 名前,
Arabic-Indic digits), so the documented [a-zA-Z0-9_-]{1,64} check
still forwarded illegal names and buyers saw an opaque provider 400.

Require name.isascii() before alnum/_/-. HTTP honesty covers Unicode
reject on chat and Responses plus a Responses 64-character keep.
Fuzz invariant matches the ASCII regex.

Co-authored-by: Seongho Bae <seonghobae@users.noreply.github.com>
@cursor

cursor Bot commented Aug 16, 2026

Copy link
Copy Markdown

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.

@coderabbitai

coderabbitai Bot commented Aug 16, 2026

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 155 files, which is 55 over the limit of 100.

To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch.

Upgrade to a paid plan to raise the limit.

This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 52b90876-a41f-4c3e-8671-650a5a57dd37

📥 Commits

Reviewing files that changed from the base of the PR and between 6841b71 and 8251149.

📒 Files selected for processing (155)
  • CHANGELOG.md
  • conductor/tracks.md
  • contextual_orchestrator/cost_ledger.py
  • contextual_orchestrator/orchestrator.py
  • contextual_orchestrator/server.py
  • docs/architecture.md
  • docs/fuzzing.md
  • docs/library_research.md
  • docs/papers/README.md
  • docs/rest_api_design.md
  • fuzz/targets.py
  • tests/fuzz/test_fuzz_properties.py
  • tests/test_analytics_runtime.py
  • tests/test_assistant_refusal_annotations_http_honesty.py
  • tests/test_assistant_tool_calls_null_noop_http_honesty.py
  • tests/test_audio_websearch_reasoning_null_noop_http_honesty.py
  • tests/test_background_reasoning_reject_http_honesty.py
  • tests/test_batch_embeddings.py
  • tests/test_batch_embeddings_encoding_dimensions_http_honesty.py
  • tests/test_batch_embeddings_endpoint_http_honesty.py
  • tests/test_batch_embeddings_routing_http_honesty.py
  • tests/test_batch_embeddings_user_http_honesty.py
  • tests/test_budget_enforcement.py
  • tests/test_chat_assistant_tool_calls_http_honesty.py
  • tests/test_chat_attribution_routing_http_honesty.py
  • tests/test_chat_audio_web_search_reject_http_honesty.py
  • tests/test_chat_developer_multimodal_content_http_honesty.py
  • tests/test_chat_empty_user_system_content_http_honesty.py
  • tests/test_chat_include_orchestration_trace_http_honesty.py
  • tests/test_chat_include_reject_http_honesty.py
  • tests/test_chat_logit_bias_http_honesty.py
  • tests/test_chat_max_completion_tokens_http_honesty.py
  • tests/test_chat_max_tool_calls_http_honesty.py
  • tests/test_chat_message_name_http_honesty.py
  • tests/test_chat_modalities_http_honesty.py
  • tests/test_chat_n_gt1_http_honesty.py
  • tests/test_chat_openai_metadata_http_honesty.py
  • tests/test_chat_orchestration_mode_http_honesty.py
  • tests/test_chat_parallel_tool_calls_http_honesty.py
  • tests/test_chat_penalties_http_honesty.py
  • tests/test_chat_prediction_http_honesty.py
  • tests/test_chat_reasoning_effort_http_honesty.py
  • tests/test_chat_reasoning_object_reject_http_honesty.py
  • tests/test_chat_response_format_http_honesty.py
  • tests/test_chat_service_tier_http_honesty.py
  • tests/test_chat_store_http_honesty.py
  • tests/test_chat_stream_options_http_honesty.py
  • tests/test_chat_temperature_top_p_http_honesty.py
  • tests/test_chat_tool_call_id_http_honesty.py
  • tests/test_chat_tool_choice_functions_http_honesty.py
  • tests/test_chat_tools_shape_http_honesty.py
  • tests/test_chat_top_logprobs_http_honesty.py
  • tests/test_chat_unknown_fields_http_honesty.py
  • tests/test_commercial_readiness.py
  • tests/test_completions_chat_era_fields_reject_http_honesty.py
  • tests/test_completions_empty_tools_noop_http_honesty.py
  • tests/test_completions_include_reject_http_honesty.py
  • tests/test_completions_legacy_knobs_http_honesty.py
  • tests/test_completions_max_completion_tokens_http_honesty.py
  • tests/test_completions_max_tokens_http_honesty.py
  • tests/test_completions_max_tool_calls_http_honesty.py
  • tests/test_completions_metadata_service_tier_http_honesty.py
  • tests/test_completions_prompt_shape_http_honesty.py
  • tests/test_completions_response_format_audio_null_http_honesty.py
  • tests/test_completions_response_format_reject_http_honesty.py
  • tests/test_completions_sampling_knobs_http_honesty.py
  • tests/test_completions_seed_http_honesty.py
  • tests/test_completions_stop_http_honesty.py
  • tests/test_completions_store_http_honesty.py
  • tests/test_completions_stream_options_http_honesty.py
  • tests/test_completions_stream_reject_http_honesty.py
  • tests/test_completions_tool_choice_function_call_noop_http_honesty.py
  • tests/test_completions_tools_noop_extensions_http_honesty.py
  • tests/test_completions_tools_reject_http_honesty.py
  • tests/test_completions_top_logprobs_reject_http_honesty.py
  • tests/test_cost_review_server.py
  • tests/test_embeddings_blank_input_http_honesty.py
  • tests/test_embeddings_encoding_format_http_honesty.py
  • tests/test_embeddings_metadata_http_honesty.py
  • tests/test_embeddings_model_pool_http_honesty.py
  • tests/test_embeddings_null_optional_noop_http_honesty.py
  • tests/test_embeddings_routing_http_honesty.py
  • tests/test_embeddings_user_field_http_honesty.py
  • tests/test_empty_modalities_prediction_noop_http_honesty.py
  • tests/test_empty_stop_array_noop_http_honesty.py
  • tests/test_empty_stream_options_include_noop_http_honesty.py
  • tests/test_empty_string_controls_noop_http_honesty.py
  • tests/test_empty_string_encoding_tool_choice_endpoint_noop_http_honesty.py
  • tests/test_empty_string_numeric_controls_noop_http_honesty.py
  • tests/test_empty_string_reasoning_text_include_noop_http_honesty.py
  • tests/test_empty_string_stop_noop_http_honesty.py
  • tests/test_empty_tools_array_http_honesty.py
  • tests/test_function_call_reasoning_empty_noop_http_honesty.py
  • tests/test_functions_null_max_tool_calls_null_http_honesty.py
  • tests/test_include_orchestration_trace_null_noop_http_honesty.py
  • tests/test_json_schema_inner_fields_omit_http_honesty.py
  • tests/test_json_schema_name_charset_http_honesty.py
  • tests/test_ledger_execution_identity_http_honesty.py
  • tests/test_message_audio_function_call_http_honesty.py
  • tests/test_message_name_empty_omit_http_honesty.py
  • tests/test_message_name_null_noop_http_honesty.py
  • tests/test_message_prefix_http_honesty.py
  • tests/test_message_unknown_fields_http_honesty.py
  • tests/test_message_weight_http_honesty.py
  • tests/test_multimodal_content_parts_shape_http_honesty.py
  • tests/test_multimodal_message_content_http_honesty.py
  • tests/test_openai_models_listing_http.py
  • tests/test_openai_passthrough.py
  • tests/test_openai_sdk_control_fields_reject_http_honesty.py
  • tests/test_openai_user_field_http_honesty.py
  • tests/test_prediction_modalities_model_strip_http_honesty.py
  • tests/test_prompt_cache_retention_reject_http_honesty.py
  • tests/test_reasoning_effort_none_store_stream_empty_noop_http_honesty.py
  • tests/test_responses_attribution_routing_http_honesty.py
  • tests/test_responses_conversation_controls_http_honesty.py
  • tests/test_responses_instructions_reasoning_http_honesty.py
  • tests/test_responses_logit_bias_logprobs_http_honesty.py
  • tests/test_responses_max_output_tokens_http_honesty.py
  • tests/test_responses_max_tokens_http_honesty.py
  • tests/test_responses_max_tool_calls_reject_http_honesty.py
  • tests/test_responses_metadata_http_honesty.py
  • tests/test_responses_modalities_prediction_http_honesty.py
  • tests/test_responses_model_required_http_honesty.py
  • tests/test_responses_n_http_honesty.py
  • tests/test_responses_parallel_tool_calls_http_honesty.py
  • tests/test_responses_penalties_http_honesty.py
  • tests/test_responses_response_format_http_honesty.py
  • tests/test_responses_seed_stop_http_honesty.py
  • tests/test_responses_service_tier_http_honesty.py
  • tests/test_responses_store_http_honesty.py
  • tests/test_responses_stream_options_http_honesty.py
  • tests/test_responses_stream_reject_http_honesty.py
  • tests/test_responses_temperature_top_p_http_honesty.py
  • tests/test_responses_tools_shape_http_honesty.py
  • tests/test_responses_user_field_http_honesty.py
  • tests/test_sales_readiness.py
  • tests/test_sdk_null_legacy_controls_noop_http_honesty.py
  • tests/test_sdk_null_object_optional_noop_http_honesty.py
  • tests/test_sdk_null_optional_noop_http_honesty.py
  • tests/test_security_hardening.py
  • tests/test_service_tier_encoding_format_strip_http_honesty.py
  • tests/test_stream_null_noop_http_honesty.py
  • tests/test_stream_options_false_tool_choice_empty_noop_http_honesty.py
  • tests/test_stream_options_null_flags_noop_http_honesty.py
  • tests/test_streaming.py
  • tests/test_tool_choice_auto_without_tools_noop_http_honesty.py
  • tests/test_tool_choice_strip_modalities_text_noop_http_honesty.py
  • tests/test_tool_description_blank_omit_http_honesty.py
  • tests/test_tool_description_length_http_honesty.py
  • tests/test_tool_description_parameters_null_noop_http_honesty.py
  • tests/test_tool_function_null_fields_pop_http_honesty.py
  • tests/test_tool_strict_null_noop_http_honesty.py
  • tests/test_top_logprobs_zero_omit_noop_http_honesty.py
  • tests/test_true_streaming.py
  • tests/test_user_null_omit_noop_http_honesty.py

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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.

@cursor cursor 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.

Unique tip 8251149 — SOUND

Reviewed only fix(api): require ASCII for json_schema.name charset on the #654 substrate. The 155-file honesty stack is out of scope and must not land on main as one merge.

What this tip does

#654 documented OpenAI Structured Outputs [a-zA-Z0-9_-]{1,64} but used str.isalnum(), which accepts Unicode letters and digits. This tip requires name.isascii() before alnum/_/- so café, 名前, and schema_١٢٣ return 400 invalid_response_format on /v1/chat/completions and /v1/responses. Empty/whitespace names still fail on the existing non-empty check. A 64-character ASCII name still echoes on mock echo.response_format. The request-body fuzz invariant now requires ASCII.

Evidence

  • Unique-tip review: no Critical or Important issues.
  • python3 tests/test_json_schema_name_charset_http_honesty.py printed ok (Unicode reject + Responses 64-character keep).
  • GitHub Checks were still queued at review time; that is not a blocker for this verdict. Re-run Full unit + Semgrep on this tip after they finish.

Residual (do not fold onto this PR)

Official Responses text.format stays on #657 / #666. The same isalnum()-without-isascii() hole remains on tool.function.name, tool_calls.function.name, and message name — next unique tip, not this one.

Reviewer next action

Land only 8251149 after Full unit + Semgrep. Do not APPROVE or squash the honesty stack onto main. Do not add text.format here.

Buyer next action

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 — rename the schema to the ASCII charset, then retry.

Open in Web View Automation 

Sent by Cursor Automation: Fix Issues

@seonghobae
seonghobae enabled auto-merge (squash) August 16, 2026 17:06
@seonghobae seonghobae closed this Aug 16, 2026
auto-merge was automatically disabled August 16, 2026 18:22

Pull request was closed

@seonghobae

Copy link
Copy Markdown
Contributor Author

Superseded by tip #691 (cumulative honesty substrate ≥ #689). Closing to free Full unit + Semgrep runners.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants