Skip to content

fix(server,mcp): harden /import limit, /mcp body+CORS, and resolve_id - #1359

Merged
ajianaz merged 2 commits into
developfrom
fix/import-limit-mcp-hardening
Oct 7, 2026
Merged

ajianaz merged 2 commits into
developfrom
fix/import-limit-mcp-hardening

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

What

Four consistency/hardening items from #1328:

  • /import: content cap is now MAX_PAYLOAD_SIZE and the 413 message reports it (was a hardcoded 5MB while read_body allows 10MB).
  • /mcp: Content-Length is 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. uuid moves 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 new resolve_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 warnings and cargo fmt --all -- --check clean; cargo run -p docgen produces no diff.

🤖 Generated with Claude Code

ajianaz and others added 2 commits October 7, 2026 20:59
…#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).
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit efafe94 into develop Oct 7, 2026
15 checks passed
@ajianaz
ajianaz deleted the fix/import-limit-mcp-hardening branch October 7, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: align /import size limit and harden /mcp & id handling

1 participant