Repository navigation
fix: validate timeout_limit at the HTTP entry point instead of panicking on inf - #135
Merged
Merged
Conversation
sahenjp
pushed a commit
that referenced
this pull request
Nov 11, 2026
🤖 I have created a release *beep* *boop* --- ## [0.31.2](v0.31.1...v0.31.2) (2026-11-11) ### Bug Fixes * parse the LLM query array as JSON instead of splitting on commas ([#134](#134)) ([fee1a93](fee1a93)) * update rustix to 1.1.6 for RUSTSEC-2026-0486 ([c07945e](c07945e)) * validate timeout_limit at the HTTP entry point instead of panicking on inf ([#135](#135)) ([f318d72](f318d72)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.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
Validate the
timeout_limitrequest parameter at the HTTP entry point and return 400 for invalid values, as prescribed by A07 indocs/AUDIT-2026-11-02.md./search?q=rust&format=json&timeout_limit=infpreviously panicked the request task inDuration::from_secs_f64.Root cause
src/web/handlers.rscopiedparams.timeout_limitinto the query unchecked, andsrc/aggregator.rsfed it toDuration::from_secs_f64after only a.max(0.1)floor, which does not stopinf(or a finite value too large to represent as aDuration). The configuredsearch.timeout_limithad no validation either, even though TOML can expressinf.Changes
src/web/handlers.rs: a suppliedtimeout_limitmust be finite, greater than 0 and at most 60 seconds; anything else is a 400 (JSON error body forformat=json, error page otherwise), following the existing language-parameter validation pattern.src/aggregator.rs: the shared predicateis_valid_timeout_limitand the cap live next toSearchRequest. The deadline computation resolves the effective value throughresolve_timeout_limit— an invalid override arriving through the library API, which bypasses the HTTP validation, falls back to the configured limit — and usestry_from_secs_f64, so this path can no longer panic.src/settings.rs:search.timeout_limitis validated likefetch.timeout(finite, positive, representable), so a config file cannot smuggleinfin either.fetch.timeouttest.About the 60 second cap: the audit asks for a server limit but does not name a value. 60 seconds is 20x the 3.0 second default and matches the largest timeout already present in the settings (research/LLM timeouts, 60s). Happy to adjust if another value is preferred.
No dependencies or response fields change. Valid requests behave as before.
Verification
Linux x86_64, Rust 1.99.1:
timeout_limit=inf,nan,-5and3600all return 400 ({"error":"timeout_limit must be a finite number of seconds greater than 0 and at most 60"}for JSON);timeout_limit=2.5returns 200 and the server stays healthy afterwards.cargo test --all-targets: 1110 passed, 1 failed. The failure istests/pdf_pages.rs(Japanese PDF text extraction), which needs Poppler Japanese CMap data that is not installed in this sandbox; it fails identically on unmodifiedmainand is unrelated to this change. Proxy environment variables were excluded from the test process for the loopback fixtures, as in fix: reject executable schemes in search results #52.cargo fmt --all --check: passed.cargo clippy --all-targets -- -D warnings: passed.Limitations
Other platforms are left to CI. The library-API fallback does not apply the 60 second cap to a configured value (only the HTTP entry point enforces the cap); it only guarantees the deadline computation cannot panic.
Related
Addresses A07 in the existing audit.
AI assistance: implementation and tests.