fix(api): digit-string n/best_of; JS bool 0/1 echo/background/logprobs - #698
fix(api): digit-string n/best_of; JS bool 0/1 echo/background/logprobs#698seonghobae wants to merge 28 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.
Null flag values on allowed keys (include_usage / include_obfuscation) stay
omit-equivalent. Dropping nulls before the allow-list made {unknown: null}
look empty and silently omit — dishonest for buyers. Fail closed with
invalid_stream_options on chat, Completions, and Responses. Tip substrate
from #638. Local full unit: 996 passed.
…ix/mode/metadata) Parallel tip #653 lacked later omit seams. Restore top_logprobs empty-string omit, tool_calls arguments null→empty string, Responses instructions blank omit, Completions whitespace suffix omit, mode strip, and metadata null value key-omit. Fail-closed paths for nonzero/non-string remain.
#668 restored accept-path 200s but left omit-equivalent keys on the proxied body. Write back empty tool_calls arguments, pop blank Responses instructions, persist cleaned metadata, and hoist chat logprobs/top_logprobs before tools passthrough so providers see the omit-equivalent payload. 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() on tool.function.name, tool_calls function.name,
message name, and response_format.json_schema.name (plus 64-char cap on
json_schema.name). HTTP honesty locks Unicode reject and legal keep on
chat and Responses. Request-body fuzz exercises both validators.
Re-lands parallel tip #685/#669 seams onto the highest #686 substrate.
The gateway rejected all non-empty text as invalid_text, so official SDK
defaults (text.format.type=text) and structured json_object/json_schema
never reached the provider. Accept the official plane, pop null/blank
optionals, fail-closed on verbosity and dual-plane text+response_format,
and require ASCII [a-zA-Z0-9_-]{1,64} on flat json_schema names.
Mock echo includes text so HTTP honesty locks forward shape. Re-lands
parallel tip #681 onto the #687 substrate.
OpenAI SDKs send truncation auto/disabled; this gateway has no multi-turn conversation window to truncate, so those values are omit-equivalent. Unknown truncation strings remain fail-closed with invalid_truncation. Also align conversation-controls tests with official text.format text.
Pop null/blank description and null strict inside response_format.json_schema before passthrough, and fail closed on unknown nested keys — parity with Responses text.format structured-output honesty.
Fail closed when tool_choice=required is sent without a non-empty tools array (chat + Responses), matching parallel_tool_calls=true honesty so clients cannot mandate tool use with no tools declared.
Reject blank metadata keys on chat/Responses so cost and observability surfaces never index empty labels; non-empty keys keep the existing 16-entry and length contracts.
…nals SDK clients send service_tier as " AUTO " and routing optionals as null. Casefold after strip so auto/default match; treat routing channel/priority empty and latency_tolerant null as omit. flex/priority and non-boolean latency_tolerant remain fail-closed.
…seed JS SDKs often send 0/1 for booleans and integer seeds as strings. Accept int 0/1 (not True/False via int subclass) for store, stream, and parallel_tool_calls; parse digit strings for seed (Responses passthrough; Completions still fail-closed after type check as unsupported).
Assistants-style tool_resources must not surface as opaque unknown_fields. Accept the key for named invalid_tool_resources; JSON null and empty object are treat-as-omit on chat, Completions, and Responses.
Coerce digit-string n and best_of (write back int) on Completions/chat/ Responses. Accept JS int 0/1 for echo, background, and logprobs via the shared optional-bool helper; digit-string top_logprobs "0" is omit. Tip-substrate from #697; local unit: 1091 passed.
|
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. |
|
Important Review skippedToo many files! This PR contains 159 files, which is 59 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (159)
You can disable this status message by setting the 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. Comment |
Summary
n/best_ofcoerce to int (write-back) on Completions, chat, and Responses; still fail-closed forn>1/best_of>1.0/1forecho,background, andlogprobsvia_coerce_optional_bool(omit/false no-op; true remains named reject where unsupported).top_logprobs: "0"omit-equivalent on chat and Completions.tool_resourcesnamed reject + cumulative honesty band). Local unit: 1091 passed.Test plan
tests/test_digit_n_bool01_echo_logprobs_http_honesty.py(12)python -m pytest tests -q(1091 passed)