[STRATCONN-6520][LinkedIn Audiences] Handle 401 errors from update audiences endpoint#3559
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3559 +/- ##
==========================================
+ Coverage 80.23% 80.24% +0.01%
==========================================
Files 1270 1270
Lines 23456 23460 +4
Branches 4695 4691 -4
==========================================
+ Hits 18819 18825 +6
+ Misses 3763 3761 -2
Partials 874 874 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
30a3235 to
520c113
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the LinkedIn Audiences destination where 401 authentication errors were being incorrectly handled as retryable 500 errors, preventing the OAuth token refresh flow from executing properly. The fix explicitly checks for 401 status codes and throws InvalidAuthenticationError to trigger the framework's token refresh mechanism.
Changes:
- Added explicit 401 error handling to throw
InvalidAuthenticationErrorand trigger OAuth refresh - Added stats tracking with status codes for all error responses to monitor error types
- Added comprehensive test coverage for both 401 (authentication) and 404 (retryable) error scenarios
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/destination-actions/src/destinations/linkedin-audiences/updateAudience/functions.ts | Added InvalidAuthenticationError import, explicit 401 handling before generic error handling, and stats tracking for errors with status codes |
| packages/destination-actions/src/destinations/linkedin-audiences/updateAudience/tests/index.test.ts | Added two new test cases covering 401 authentication errors and 404 retryable errors |
|
PR deployed |
In this PR, we fix a bug in update audience response handling logic. Previously every error was marked as 500 leading to large of number retryable_errors even for 401. For 401s, the immediate retry logic in actions should execute. In this PR, we do two things
Testing
Tested for happy path scenario in stage
401 scenario - linkedin audiences token are valid for a long time. So, tried to simulate an invalid token in local and captured the results here
Security Review
Please ensure sensitive data is properly protected in your integration.
type: 'password'New Destination Checklist
verioning-info.tsfile. example