Repository navigation
fix(server,mcp): harden /import limit, /mcp body+CORS, and resolve_id - #1359
Merged
Merged
Conversation
…#1328) - /import: the content cap now equals MAX_PAYLOAD_SIZE and the error reports it, instead of a hardcoded 5MB that disagreed with read_body's 10MB. - /mcp: match Content-Length case-insensitively, read one byte past the cap so an unsized oversized body is a 413 rather than a truncated JSON parse error, and attach CORS headers like every other endpoint. - resolve_id: accept only hex/dash input (no LIKE wildcards reach the prefix scan), skip the scan only for a parseable UUID, and let a 36-char non-UUID fall to the prefix path so it errors like the 8-char path. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Keep both new test sets in uteke-mcp (resolve_id hardening and full_ids).
🔍 Cora AI Code Review✅ No issues found. Code looks good! Review powered by cora-code · BYOK · MIT |
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.
What
Four consistency/hardening items from #1328:
/import: content cap is nowMAX_PAYLOAD_SIZEand the 413 message reports it (was a hardcoded 5MB whileread_bodyallows 10MB)./mcp:Content-Lengthis matched case-insensitively (HeaderField::equiv); the body is read one byte past the cap so an unsized oversized request returns 413 instead of a truncated-JSON parse error./mcp: responses now carry the same CORS headers as the other endpoints.resolve_id(uteke-mcp): accepts only hex digits and dashes (keeps LIKE wildcards%/_out of the prefix scan), skips the scan only for a parseable UUID, and sends a 36-char non-UUID through the prefix path so it errors like an 8-char id.uuidmoves from dev-dependency to dependency (already in the lockfile).Why
Tracked in #1328 (split out of the v0.19.1 review #1319). Inconsistent limits and error shapes make clients guess, and the 36-byte shortcut accepted arbitrary strings as full ids.
Closes #1328
Testing
cargo test -p uteke-mcp -p uteke-server: all pass, including newresolve_id_rejects_malformed_ids,mcp_oversized_body_is_413,mcp_response_has_cors_headers.cargo clippy -p uteke-mcp -p uteke-server --all-targets -- -D warningsandcargo fmt --all -- --checkclean;cargo run -p docgenproduces no diff.🤖 Generated with Claude Code