Repository navigation
Conversation
* fix: remove userid/deviceid level throttler handler for am * chore: address comment * chore: update varaible name
Summary by CodeRabbit
WalkthroughRefactored error handling in the AM destination networkHandler to normalize error extraction and simplify throttling logic. Replaced direct response.error access with a normalized errorResponse variable, removed conditional checks for throttled users/devices in the 429 path, and now consistently throws ThrottledError. No public API changes. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Areas requiring attention:
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/v1/destinations/am/networkHandler.ts (1)
81-87: Reuse theerrorMessagevariable to eliminate duplication.Line 83 duplicates the stringification logic from line 38. Since
errorMessageis already defined, use it directly to improve maintainability.Apply this diff:
throw new AbortedError( - `Request Failed during ${DESTINATION} response transformation: with status "${status}" due to "${ - JSON.stringify(errorResponse) || 'unknown error' - }", (Aborted)`, + `Request Failed during ${DESTINATION} response transformation: with status "${status}" due to "${errorMessage}", (Aborted)`, status, destinationResponse, );
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (5)
CHANGELOG.mdis excluded by!**/*.mdpackage-lock.jsonis excluded by!**/package-lock.json,!**/*.jsonpackage.jsonis excluded by!**/*.jsonsrc/v0/destinations/am/README.mdis excluded by!**/*.mdtest/integrations/destinations/am/dataDelivery/data.tsis excluded by!**/test/**
📒 Files selected for processing (1)
src/v1/destinations/am/networkHandler.ts(3 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4654
File: src/v1/destinations/am/networkHandler.ts:50-86
Timestamp: 2025-09-24T10:41:29.258Z
Learning: In the AM destination network handler (src/v1/destinations/am/networkHandler.ts), ItsSudip confirmed that hardcoded status codes (500/400) in RetryableError and AbortedError constructors are acceptable because the actual HTTP status verification happens before setting these codes in the error flow.
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4707
File: src/v1/destinations/am/networkHandler.ts:0-0
Timestamp: 2025-10-13T03:41:56.503Z
Learning: In the AM destination network handler (src/v1/destinations/am/networkHandler.ts), the populateResponseWithDontBatch function uses conditional status codes: 400 for events that already have metadata.dontBatch=true (meaning they've been retried individually and failed), and 500 for first-time failures (to trigger an unbatched retry). This two-phase retry pattern prevents infinite retries of persistently failing events.
📚 Learning: 2025-09-24T10:41:29.258Z
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4654
File: src/v1/destinations/am/networkHandler.ts:50-86
Timestamp: 2025-09-24T10:41:29.258Z
Learning: In the AM destination network handler (src/v1/destinations/am/networkHandler.ts), ItsSudip confirmed that hardcoded status codes (500/400) in RetryableError and AbortedError constructors are acceptable because the actual HTTP status verification happens before setting these codes in the error flow.
Applied to files:
src/v1/destinations/am/networkHandler.ts
📚 Learning: 2025-10-13T03:41:56.503Z
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4707
File: src/v1/destinations/am/networkHandler.ts:0-0
Timestamp: 2025-10-13T03:41:56.503Z
Learning: In the AM destination network handler (src/v1/destinations/am/networkHandler.ts), the populateResponseWithDontBatch function uses conditional status codes: 400 for events that already have metadata.dontBatch=true (meaning they've been retried individually and failed), and 500 for first-time failures (to trigger an unbatched retry). This two-phase retry pattern prevents infinite retries of persistently failing events.
Applied to files:
src/v1/destinations/am/networkHandler.ts
📚 Learning: 2025-09-24T07:20:21.396Z
Learnt from: ItsSudip
Repo: rudderlabs/rudder-transformer PR: 4654
File: src/v0/destinations/am/config.js:127-128
Timestamp: 2025-09-24T07:20:21.396Z
Learning: For Amplitude destination, MAX_USERS_DEVICES_PER_BATCH = 1000 is correctly set based on Amplitude's throttling limit of 1000 events per second per user/device, not the per-request batch size limit. The batching logic groups events by userId/anonymousId to prevent throttling, which is separate from the AMBatchEventLimit = 500 constraint for individual API requests.
Applied to files:
src/v1/destinations/am/networkHandler.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
- GitHub Check: Code Coverage
- GitHub Check: test_and_publish
- GitHub Check: UT Tests
- GitHub Check: Analyze (javascript-typescript)
- GitHub Check: Analyze (go)
- GitHub Check: Analyze (go)
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (1)
src/v1/destinations/am/networkHandler.ts (1)
37-38: LGTM! Error extraction refactoring improves consistency.The renaming of
errortoerrorResponseand the centralized construction oferrorMessageenhance code clarity and maintainability.
|
Allure Test reports for this run are available at:
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #4745 +/- ##
===========================================
- Coverage 91.92% 91.91% -0.02%
===========================================
Files 651 651
Lines 34609 34613 +4
Branches 8121 8131 +10
===========================================
Hits 31816 31816
+ Misses 2563 2548 -15
- Partials 230 249 +19 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|



👑 An automated PR