PR 10: Narrow meta-tool JSON coercion#314
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
- Cache (signature, type_hints) per handler via _handler_meta — both ran on every dispatch before; handlers live for process lifetime so an unbounded functools.cache is safe. - Drop tuple from _json_container_kinds list-acceptors. json.loads only produces list, never tuple, so a tuple-annotated param could not be satisfied by coercion anyway. - Rename _json_container_prefix to _is_json_shaped and return bool — the prefix value was never consumed, only truth-tested. - Document the empty-set "do not coerce" policy on _json_container_kinds so a future reader does not "fix" the unannotated bypass. - Add a regression test for list[str] | None covering the Union branch. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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.
Summary
Base:
betaAddresses issue #297 finding #8 by narrowing nested JSON-string coercion in
dispatch_manage_op().The new policy is annotation-aware:
str.GodotCommandError(ErrorCode.INVALID_PARAMS)for malformed JSON-shaped text or wrong JSON container type when the handler expects list/dict-like params, withdataincludingtool,op, andparam.TypeErrorwrapping for missing/extra arguments.Compatibility is preserved for clients that stringify top-level manage
paramsand for nested stringified list/dict values where the target handler annotation expects those containers.PR 9 is being worked in parallel and this PR intentionally does not touch the GDScript self-update preload-alias scope.
Test Plan
ruff check src/ tests/pytest -v(766 passed)pytest -q tests/unit/test_meta_tool.py tests/unit/test_middleware_parse_stringified_params.py tests/unit/test_middleware_op_typo_hint.py(36 passed)script/ci-check-gdscriptscript/ci-godot-testsattempted locally; it found a Godot session, then exited with curl code 7 while openingmain.tscn. A follow-up probe showed no MCP server responding on127.0.0.1:8000.Out of Scope