fix: validate search_accounts filters (raise on unknown keys) - #14
Merged
Conversation
Apollo's /accounts/search silently drops unrecognised filter keys and
returns an unfiltered default page that looks like a real match. Passing
e.g. query='Red and Bundle' returned 28k accounts ('Google' first)
instead of the intended match, causing wrong-company attribution.
search_accounts now validates **filters against an allowlist of the keys
Apollo actually supports and raises ValueError (naming the bad key and
pointing to q_organization_name) before hitting the API. Fail-loud beats
silent-wrong. Live-verified.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This was referenced Jul 9, 2026
Merged
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.
The bug (Medium-High — silent-wrong)
search_accounts(**filters)forwarded filters unvalidated. Apollo silently drops unknown keys and returns an unfiltered default page that looks like a real match:Real impact reported: trusted the "Google" result → wrong company attached to a deal + a duplicate account created before it was caught.
Fix
ACCOUNT_SEARCH_FILTERSallowlist (from Apollo docs:q_organization_name,account_stage_ids,account_label_ids,sort_by_field,sort_ascending).search_accountsnow raisesValueErroron any unknown key before the request, naming the bad key and pointing toq_organization_name=.Testing
q_organization_namestill returns the correct single match.Note: CLI
accounts search --queryalready maps toq_organization_name, so it's unaffected. No version bump (left for release time).🤖 Generated with Claude Code