Repository navigation
fix(core): cap ZIP import and search query input sizes - #1939
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bf5791959d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| text: Optional[str] = Field( # Full-text search (supports boolean operators) | ||
| default=None, max_length=MAX_SEARCH_TEXT_CHARS |
There was a problem hiding this comment.
Validate oversized prompt inputs at the request boundary
When a caller sends more than 4,000 characters to either POST /prompt/search or POST /prompt/continue-conversation, SearchPromptRequest.query and ContinueConversationRequest.topic accept the payload, but the handlers then construct SearchQuery internally and trigger this new max_length validation. Because that ValidationError occurs inside the route rather than during request parsing, the catch-all handler converts it to a 500 instead of the intended 422. Apply the same limit to both prompt request fields or explicitly translate this validation failure.
AGENTS.md reference: AGENTS.md:L129-L130
Useful? React with 👍 / 👎.
bf57919 to
3ae4b05
Compare
Project ZIP planning matched every archive file against every archive-authored ignore pattern with no bound on either count. Cap ZIP imports at 20,000 files and 500 archive ignore patterns, failing fast with a clear error. The worst case at the caps measures about 17s on one core, against an unbounded cost before. Search text had no length limit, and Postgres boolean phrase parsing does a whole-query replacement per phrase. Cap SearchQuery.text at 4,000 characters, enforced when the API validates the request. Fixes #1899 Fixes #1893 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CMYVL1x91B8kJxy7nn2GU8 Signed-off-by: phernandez <[email protected]>
The prompt search and continue-conversation routes build SearchQuery internally, so an oversized query or topic tripped the new length cap inside the handler and surfaced as a 500. Apply the same cap to both request fields so oversize is a 422. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CMYVL1x91B8kJxy7nn2GU8 Signed-off-by: phernandez <[email protected]>
2ffca9a to
6ffd079
Compare
Why
Two CodeRabbit deep-scan findings where uploaded or caller-supplied input on hosted Cloud drives unbounded work:
.gitignore/.bmignore. Neither count had a limit; only expanded bytes did (100MB).SearchQuery.texthad no length limit.What changed
MAX_PROJECT_ZIP_FILES = 20_000andMAX_PROJECT_ZIP_IGNORE_PATTERNS = 500(archive-authored patterns only; Basic Memory defaults don't count). Both fail fast withProjectZipImportError, the same way the existing size cap does.MAX_SEARCH_TEXT_CHARS = 4_000onSearchQuery.text. The MCP search tool assigns fields after construction, so the cap is enforced when the API router validates the request body, locally and on Cloud. The similar-notes probe is capped at 900 chars, well inside the limit.I picked hard limits over the "aggregate work budget" the scan suggested. They are simpler and fail with a clear message.
Measured ZIP planning time (one core):
Verification
QUERY /v2/.../search/. Each fails without the fix.tests/api/v2, search schema and MCP search tools, project management): 665 passed, 1 skipped.just fast-check: cleanCloud picks up both caps through
build_project_zip_import_planand the core search router after the next re-pin. No Cloud code change is needed.Stacked on #1938.
🤖 Generated with Claude Code
https://claude.ai/code/session_01CMYVL1x91B8kJxy7nn2GU8