refactor: sanitize Brokkr response by filtering invalid locations in parseOpportunity function#3387
refactor: sanitize Brokkr response by filtering invalid locations in parseOpportunity function#3387
Conversation
…parseOpportunity function
|
🍹 The Update (preview) for dailydotdev/api/prod (at ea5a79a) was successful. Resource Changes Name Type Operation
~ vpc-native-update-source-tag-view-cron kubernetes:batch/v1:CronJob update
~ vpc-native-hourly-notification-cron kubernetes:batch/v1:CronJob update
~ vpc-native-post-analytics-clickhouse-cron kubernetes:batch/v1:CronJob update
~ vpc-native-personalized-digest-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-sync-subscription-with-cio-cron kubernetes:batch/v1:CronJob update
~ vpc-native-update-tag-recommendations-cron kubernetes:batch/v1:CronJob update
+ vpc-native-api-clickhouse-migration-ac2f27c3 kubernetes:batch/v1:Job create
~ vpc-native-clean-zombie-opportunities-cron kubernetes:batch/v1:CronJob update
- vpc-native-api-db-migration-f8d9095e kubernetes:batch/v1:Job delete
~ vpc-native-update-tags-str-cron kubernetes:batch/v1:CronJob update
~ vpc-native-daily-digest-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-stale-user-transactions-cron kubernetes:batch/v1:CronJob update
~ vpc-native-generic-referral-reminder-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-zombie-users-cron kubernetes:batch/v1:CronJob update
~ vpc-native-generate-search-invites-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-zombie-images-cron kubernetes:batch/v1:CronJob update
~ vpc-native-temporal-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-update-trending-cron kubernetes:batch/v1:CronJob update
~ vpc-native-personalized-digest-cron kubernetes:batch/v1:CronJob update
+ vpc-native-api-db-migration-ac2f27c3 kubernetes:batch/v1:Job create
~ vpc-native-post-analytics-history-day-clickhouse-cron kubernetes:batch/v1:CronJob update
~ vpc-native-clean-gifted-plus-cron kubernetes:batch/v1:CronJob update
~ vpc-native-update-highlighted-views-cron kubernetes:batch/v1:CronJob update
~ vpc-native-update-current-streak-cron kubernetes:batch/v1:CronJob update
~ vpc-native-bg-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-private-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-update-source-public-threshold-cron kubernetes:batch/v1:CronJob update
~ vpc-native-validate-active-users-cron kubernetes:batch/v1:CronJob update
~ vpc-native-deployment kubernetes:apps/v1:Deployment update
~ vpc-native-clean-zombie-user-companies-cron kubernetes:batch/v1:CronJob update
~ vpc-native-update-views-cron kubernetes:batch/v1:CronJob update
~ vpc-native-user-profile-updated-sync-cron kubernetes:batch/v1:CronJob update
~ vpc-native-calculate-top-readers-cron kubernetes:batch/v1:CronJob update
~ vpc-native-check-analytics-report-cron kubernetes:batch/v1:CronJob update
~ vpc-native-ws-deployment kubernetes:apps/v1:Deployment update
- vpc-native-api-clickhouse-migration-f8d9095e kubernetes:batch/v1:Job delete
|
| location: Array.isArray(result.opportunity?.location) | ||
| ? result.opportunity.location.filter((loc: Location) => { | ||
| // Only keep locations with valid country | ||
| return loc?.country && loc.country.trim().length > 0; |
There was a problem hiding this comment.
think actually we should look at those with iso2, since that one is actually important for process down the line
There was a problem hiding this comment.
but i think country is the one we make strict, right?
There was a problem hiding this comment.
should be both, gondul looks only at ISO so it can't do anything with country name
There was a problem hiding this comment.
Claude finished @idoshamun's task —— View job • claude/pr-3387-20260105-0931 • Create PR ➔
✅ Fixed location filtering to check both country and iso2
Updated the location filtering logic in parseOpportunity function to validate both country and iso2 fields, ensuring gondul has valid ISO codes for downstream processing.
Todo List:
- Read current implementation in parseOpportunity function
- Update filtering logic to check both country and iso2 fields
- Commit and push changes
- Provide PR creation link
Changes Made:
- Updated
src/common/opportunity/parse.ts:209to filter locations based on bothcountryandiso2validation - Added checks to ensure both fields are present and have non-empty trimmed values
- This prevents invalid location data from reaching gondul which requires valid ISO codes
|
@claude fix Ante's comment on a new branch |
|
Claude finished @idoshamun's task in 1m 20s —— View job • ✅ Fixed location validation to check both country and iso2Updated the location filtering logic in Todo List:
Changes Made:
|
No description provided.