fix(api): pop null tool.function optional fields omit-real before proxy - #638
fix(api): pop null tool.function optional fields omit-real before proxy#638seonghobae wants to merge 13 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.
|
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 143 files, which is 43 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 (143)
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 |
There was a problem hiding this comment.
Unique tip: SOUND — do not merge this 143-file stack onto main
569f760 is the omit-real repair #595 / #603 promised: _omit_null_tool_function_field pops JSON-null tool.function description / parameters / strict in place, and the new HTTP cases assert echo.tools no longer carries those keys. Non-null wrong types stay invalid_tools. That is the buyer-visible contract (SDK optional defaults must not reach a provider as parameters: null).
What to do next
- Do not merge #638 onto
mainas the 12-commit / 143-file honesty stack. Land the unique tip onto the current tools-honesty vehicle after Full unit + Semgrep are green on that tip. - Prefer #638 over #603 for this omit-real slice (#638 sits on the #614 message-name substrate).
- Do not open a third
tool.functionnull-pop PR. - Independent non-author APPROVE is still required. This review is COMMENT only.
Residual gaps on this tip (not merge-blockers for the unique commit)
- Docs (
docs/rest_api_design.md,docs/papers/README.md) do not yet tell a caller to send omitted optionals — or to expect this gateway to pop SDK nulls — before proxy. - The new test module claims
response_format.json_schema.strictnull is omit-real but never assertsecho.response_format. response_format.json_schema.descriptionnull/blank and unknown inner keys still pass through. That is the next unique slice; #639/#640 already claim other honesty follow-ups — do not fold those here.
Local unique script will be re-run on the successor commit. GitHub Checks (Full unit, Semgrep, Security) are not a blocker for the next unique honesty slice.
Sent by Cursor Automation: Fix Issues
| if "strict" in schema: | ||
| strict_value = schema.get("strict") | ||
| if strict_value is None: | ||
| schema.pop("strict") |
There was a problem hiding this comment.
Omit-real pop is the right contract: proxy_completion forwards this object, so leaving strict: null would still be a provider reject. The same inner object still forwards description: null / blank description and unknown sibling keys (additionalProperties, vendor extensions). Those need the same pop / fail-closed treatment before this stack is buyer-complete.
| * chat and Responses return 200 | ||
| * mock ``echo.tools`` no longer contains the null keys | ||
| * non-null wrong types stay fail-closed with named ``invalid_tools`` | ||
| * response_format.json_schema.strict null is also omit-real |
There was a problem hiding this comment.
This file claims response_format.json_schema.strict null is omit-real, but every HTTP case asserts echo.tools only. Add a chat + Responses echo assertion on echo.response_format.json_schema so a later validator that type-checks and leaves the key cannot regress silently.
There was a problem hiding this comment.
Pull request overview
OpenCode cannot approve yet because required coverage evidence did not pass.
Review outcome
1. HIGH .github/workflows/opencode-review.yml:1 - Coverage evidence did not prove required test/docstring evidence
-
Problem: The required coverage-evidence job result was
failure, so OpenCode cannot establish approval sufficiency for this head. -
Root cause: Automated approval is only valid when the same-head coverage-evidence job proves supported repository test suites passed and configured docstring gates passed or were advisory, or reports not applicable because no supported source files or package manifests exist. Missing, failed, skipped, unavailable, or unsupported-tooling test evidence is a blocker.
-
Fix: Install or configure the repository test/docstring evidence tooling when source files or package manifests exist, rerun the current-head coverage-evidence job, and approve only after it reports
successwith required evidence or explicit no-source not-applicable evidence. -
Regression test: Keep the approval branch checking
needs.coverage-evidence.result == successbefore posting APPROVE, and publish REQUEST_CHANGES when coverage-evidence blocker states such as cancelled, skipped, failed, unsupported-tooling, or below-100 evidence are present. -
Result: REQUEST_CHANGES
-
Reason: coverage-evidence result was
failure, so required test/docstring evidence was not proven for current head2c1a10f1376d1be4454f4b3d9a17d4ac4cc9c5bc. -
Head SHA:
2c1a10f1376d1be4454f4b3d9a17d4ac4cc9c5bc -
Workflow run: 32162715777
-
Workflow attempt: 1
Coverage evidence
Coverage evidence job did not run or did not publish coverage evidence.
Changed-File Evidence Map
flowchart LR
Evidence["OpenCode evidence"] --> Review["Current PR review path"]
Review --> Verify["Required checks"]
OpenCode Review Overview
Pull request overviewOpenCode cannot approve yet because required coverage evidence did not pass. Review outcome1. HIGH .github/workflows/opencode-review.yml:1 - Coverage evidence did not prove required test/docstring evidence
Coverage evidenceCoverage evidence job did not run or did not publish coverage evidence. Changed-File Evidence Mapflowchart LR
Evidence["OpenCode evidence"] --> Review["Current PR review path"]
Review --> Verify["Required checks"]
|


Summary
tool.functiondescription/parameters/strictas JSONnull.proxy_completionforwards the body and several providers reject nullparameters.invalid_tools.response_format.json_schema.strictnull.Test plan
python -m pytest tests -q(989 passed)