fix(tools): validate Brave search parameters - #1245
Merged
penso merged 3 commits intoAug 26, 2026
Merged
Conversation
Brave accepts fixed country and language values, but web_search exposed unconstrained strings and forwarded them verbatim. That allowed model-generated localization values to fail with HTTP 422. Scope the localization schema to the Brave provider, normalize optional values before sending them, and retry once without optional filters when Brave still rejects the request.
rubenssoto
force-pushed
the
fix/brave-search-parameter-validation
branch
from
August 25, 2026 17:55
78db36c to
43dd17c
Compare
Contributor
Greptile SummaryThe PR validates and normalizes Brave-specific search parameters while improving retry behavior and cache separation.
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains within the scope of this follow-up review, and the previously requested retry-path coverage is present at the current head.
|
| Filename | Overview |
|---|---|
| crates/tools/src/web_search.rs | Integrates normalized Brave parameters into schema generation, request execution, cache keys, and fully mocked retry-path tests. |
| crates/tools/src/web_search/brave.rs | Adds provider-local enum definitions and normalization logic for Brave localization and freshness parameters. |
Reviews (2): Last reviewed commit: "fix(tools): preserve Brave search contex..." | Re-trigger Greptile
Exercise the Brave HTTP path with a mock server so the 422 fallback cannot regress silently. Verify sanitized first-request parameters, a filter-free retry, preserved headers, successful retry parsing, no retry without filters, and propagation of the retry response error.
Include normalized localization, freshness, and accepted language in Brave cache keys so distinct searches cannot reuse mismatched results. Also infer simplified or traditional Chinese from supported Brave regions.
Contributor
Author
|
Addressed two additional correctness cases in
Added regression coverage for normalized cache-key equivalence/separation and both Chinese scripts. Validation passes: 43 targeted @greptile-apps please re-review the updated head. |
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
ALLzh-hansorzh-hantfrom supported Chinese country/UI regions when callers provide the genericzhlanguageAccept-LanguagecontextValidation
Completed
cargo fmt --all -- --checkgit diff --check./scripts/check-file-size.shcargo test --locked -p moltis-tools --all-features web_search -- --nocapture(43 passed)cargo clippy --locked -p moltis-tools --all-features --all-targets -- -D warnings./scripts/local-validate.sh 1245ata035d594(partial: fmt, Biome, TypeScript, i18n, zizmor, install checks, file-size, lockfile, and web assets passed)a035d594; the cache/Chinese normalization follow-up was validated with targeted tests and clippyRemaining
llama-cpp-sys-2dependencyManual QA
moltis-local:20260824.01-obscura-v021-brave-pr1245; the gateway started normally and/healthreturned HTTP 200country=ALL,search_lang=es, invalidui_langomitted,freshness=pw) from the running container; Brave returned HTTP 200 with three results