Repository navigation
fix(mcp): support UUID serialization in fixes and knowledge subclients - #115
Open
nitinkoberoii wants to merge 2 commits into
Open
nitinkoberoii wants to merge 2 commits into
nitinkoberoii wants to merge 2 commits into
Conversation
This branch has not been deployed
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.
Problem
Core
ProoflineClientandAsyncProoflineClientmethods accept and returnuuid.UUIDobjects for identifiers (organization_id,review_id,finding_id, etc.). However, the MCP subclients (client.fixesandclient.knowledge) serialized JSON-RPC payloads with standardjson.dumps(value)inproofline/_mcp.py.Passing a
UUIDdirectly from a core SDK model into an MCP method crashed at runtime before any HTTP request was sent:Approach
proofline/_mcp.py: Replaced json.dumps(value) with json.dumps(value, default=_json_default), where _json_default explicitly converts uuid.UUID instances to str and raises TypeError for all other unserializable types.proofline/fixes.py&proofline/knowledge.py: Updated ID parameter annotations across both sync and async clients to accept UUID | str (or UUID | str | None where optional), and typed finding_ids in request_reverification as Sequence[UUID | str] so list[UUID], list[str], and tuple[UUID, ...] all type-check cleanly.Verification
Added sync and async regression tests in
tests/test_http.pycovering:Passing UUID objects to
client.fixesandclient.knowledgemethods and verifying the serialized JSON-RPC arguments payload.Passing list[UUID] and tuple[UUID, ...] to request_reverification.
Confirming that passing a set or other unserializable object still raises TypeError.
Confirming that cyclic containers still raise ValueError.
Reproducible local checks run:
All tests, linting, formatting, type checks, and contract checks pass.
Proofline Review Evaluation
I installed Proofline on my GitHub organization (
My-Org-Nitin/sdk-python) and ran a review on my initial PR before opening this upstream PR.What Proofline caught (and what I changed):
Serious · Error handling): My first implementation used a recursive _serialize_mcp_value walker, which would hit RecursionError on cyclic containers before json.dumps could raise ValueError.Warning · Performance): The recursive walker copied shared references on every visit (Warning · Logic): Annotating finding_ids as list[UUID | str] breaks mypy for callers passing list[UUID] or list[str].Warning · Edge case): Using a list comprehension over finding_ids silently converted a set into a list instead of letting json.dumps reject it with TypeError.Replacing the manual walker and list comprehension with a strict json.dumps(..., default=_json_default) hook and Sequence[UUID | str] resolved all four issues cleanly.
Product feedback:
Proofline flagged the list[UUID | str] invariance issue twice on the exact same lines—once under Logic and once under Api contract. Deduplicating overlapping findings across categories would make the review signal even sharper.