Fix BUILD-1144: Prevent Neynar API 20-character limit error#49
Merged
Conversation
Addresses BUILD-1144 where Ethereum addresses (42 chars) caused 400 Bad Request errors when searching users via Neynar API, which requires q param ≤20 chars. Changes: - Add input validation in searchUsersByUsername() before API call - Handle Ethereum addresses (0x + 42 chars) with specific error message - Handle any query >20 chars with generic length error message - Update /search route to return 400 with descriptive errors - Add comprehensive tests for validation edge cases 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
BUILD-1144 Neynar has a lookup by name requirement of 20 characters
|
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 BUILD-1144 where Ethereum addresses (42 characters) caused 400 Bad Request errors when searching users via the Neynar API, which has a requirement that the
qparameter must be 20 characters or less.Changes
searchUsersByUsername()to check string length0x/searchroute to return proper 400 responses with descriptive messagesRoot Cause
The Neynar
/v2/farcaster/user/searchendpoint validates that theqparameter is ≤20 characters. When users attempted to search with Ethereum addresses like0x0B5f5a722Ac5E8EcEDf4da39A656fe5f1e76b34C, the API returned:{"code":"InvalidField","message":"q must be a string of length 20 or less","property":"q"}Solution
Test Plan
🤖 Generated with Claude Code