Make optional Python RPC requests omittable - #2556
Open
kondv wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Two moderate required-null handling issues remain unresolved in Python code generation.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Enables omission of Python RPC request objects when allowed by the original schema while preserving required nullable fields.
Changes:
- Adds draft-2019-09 schema validation for request optionality.
- Regenerates Python RPC APIs and adds regression tests.
- Updates dependencies and quota documentation.
File summaries
| File | Review |
|---|---|
scripts/codegen/python.ts |
Two moderate issues: required nulls are dropped in optional session requests, and required opaque-JSON fields remain optional. |
scripts/codegen/package.json |
Adds AJV dependency. |
scripts/codegen/package-lock.json |
Locks codegen dependencies. |
python/test_rpc_generated.py |
Adds generated signature and serialization tests. |
python/copilot/generated/rpc.py |
Updates generated Python RPC models and methods. |
nodejs/test/python-codegen.test.ts |
Tests schema evaluation and code generation. |
nodejs/package.json |
Adds AJV for codegen tests. |
nodejs/package-lock.json |
Locks test dependencies. |
docs/features/usage-and-billing.md |
Documents argument-free quota retrieval. |
Review details
Files not reviewed (2)
- nodejs/package-lock.json: Generated file
- scripts/codegen/package-lock.json: Generated file
Suppressed comments (1)
scripts/codegen/python.ts:3957
- The server-method path has the same optional-wrapper/required-nullable interaction: filtering
Nonehere drops a required field when the request object is supplied explicitly. Selectparams.to_dict()whenpreserveRequiredNullsis true, while retaining{}for an omitted request.
if (paramsOptional) {
lines.push(` params_dict = {k: v for k, v in params.to_dict().items() if v is not None} if params is not None else {}`);
} else if (preserveRequiredNulls) {
lines.push(` params_dict = params.to_dict()`);
- Files reviewed: 6/9 changed files
- Comments generated: 2
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+3220
to
3224
| if (requiredNullableFields.size > 0) { | ||
| requiredNullableRequestFieldsByClass.set( | ||
| paramsTypeName, | ||
| new Set([...requiredNullableFields].map(toSnakeCase)) | ||
| ); |
Comment on lines
3940
to
3945
| if (paramsOptional) { | ||
| lines.push(` params_dict: dict[str, Any] = {k: v for k, v in params.to_dict().items() if v is not None} if params is not None else {}`); | ||
| } else if (preserveRequiredNulls) { | ||
| lines.push(` params_dict: dict[str, Any] = params.to_dict()`); | ||
| } else { | ||
| lines.push(` params_dict: dict[str, Any] = {k: v for k, v in params.to_dict().items() if v is not None}`); |
kondv
force-pushed
the
dev/kondv/python-get-quota-optional
branch
from
September 7, 2026 12:45
eb61822 to
fd63cf1
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1946
Summary
Generate optional Python RPC request parameters when the original JSON Schema accepts the caller omitting the request object.
Optionality is evaluated against the original draft-2019-09 schema before codegen normalization, including references, Boolean schemas, combinators, property-count constraints, and injected session fields. Required nullable fields remain required, and explicitly supplied
Nonevalues are preserved as JSON null. The generated Python API and quota documentation are updated accordingly.Validation
tyget_quota()succeeded without an argumentsubagents=Nonecrossed the RPC boundary as JSON null