fix: prevent DEFAULT_PARAMETERS from overriding user-provided values#128
Open
spidershield-contrib wants to merge 2 commits into
Open
fix: prevent DEFAULT_PARAMETERS from overriding user-provided values#128spidershield-contrib wants to merge 2 commits into
spidershield-contrib wants to merge 2 commits into
Conversation
The default parameter application loop iterated over searchParams keys and unconditionally replaced them with values from defaults. This caused user-provided parameter values (e.g., max_results=10) to be silently overwritten by DEFAULT_PARAMETERS (e.g., max_results=5). Reverse the iteration to loop over defaults keys instead, and only apply a default when the user-provided value is undefined or null.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
The || [] fallback on include_domains/exclude_domains prevented DEFAULT_PARAMETERS from ever applying to these fields, since their value was always [] (never undefined/null). Move the [] fallback to after default parameter application so domain list defaults work correctly. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.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
Fixes #127
The default parameter application loop iterated over
searchParamskeys and unconditionally replaced matching values fromdefaults. This caused user-provided values to be silently overwritten by DEFAULT_PARAMETERS.Changes
src/index.tsdefaultskeys, only apply when user value is undefined/nullBefore / After
Before (buggy):
After (fixed):
Test Plan
npx tsc --noEmit— zero errorsDEFAULT_PARAMETERS='{"max_results":5}', callingtavily_search(query="test", max_results=10)should return 10 results (not 5)DEFAULT_PARAMETERS='{"search_depth":"basic"}', callingtavily_search(query="test")should use "basic" (default fills the gap)Note
Low Risk
Low risk: changes are localized to
tavily_searchrequest parameter merging and should only affect how defaults are applied; main risk is subtle behavior changes for callers relying on old (buggy) overriding behavior.Overview
Fixes
tavily_searchparameter merging soDEFAULT_PARAMETERSno longer overwrites explicitly provided user arguments; defaults are now applied only when the user value isundefined/null.Also normalizes
include_domains/exclude_domainsso they are neverundefined(coalesced to[]) to match the Tavily API’s expected array types.Written by Cursor Bugbot for commit b7b2a3a. This will update automatically on new commits. Configure here.
Found by SpiderShield security scanner