Skip to content

[STRATCONN-6520][LinkedIn Audiences] Handle 401 errors from update audiences endpoint#3559

Merged
joe-ayoub-segment merged 1 commit intomainfrom
fix/linkedin-audiences-401-handling
Feb 3, 2026
Merged

[STRATCONN-6520][LinkedIn Audiences] Handle 401 errors from update audiences endpoint#3559
joe-ayoub-segment merged 1 commit intomainfrom
fix/linkedin-audiences-401-handling

Conversation

@varadarajan-tw
Copy link
Contributor

@varadarajan-tw varadarajan-tw commented Feb 2, 2026

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

  • propagate 401 errors properly
  • add stats to look at error types of other errors from retryable erorr. After looking at status, we can specifically mark error codes that are retryable as retryable instead of all erorr codes. The expectation is 404 should be retried for linkedin audience. 404 signals an audience created not being ready to accept data but to be safe, we log all errors and then decide the retryable error codes.

Testing

Tested for happy path scenario in stage

image

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

  • Added unit tests for new functionality
  • Tested end-to-end using the local server
  • [] [If destination is already live] Tested for backward compatibility of destination. Note: New required fields are a breaking change.
  • [Segmenters] Tested in the staging environment
  • [Segmenters] [If applicable for this change] Tested for regression with Hadron.

Security Review

Please ensure sensitive data is properly protected in your integration.

  • Reviewed all field definitions for sensitive data (API keys, tokens, passwords, client secrets) and confirmed they use type: 'password'

New Destination Checklist

  • Extracted all action API versions to verioning-info.ts file. example

@codecov
Copy link

codecov bot commented Feb 2, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.24%. Comparing base (f2000ba) to head (520c113).
⚠️ Report is 1 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@varadarajan-tw varadarajan-tw marked this pull request as ready for review February 2, 2026 11:51
@varadarajan-tw varadarajan-tw requested a review from a team as a code owner February 2, 2026 11:51
@varadarajan-tw varadarajan-tw changed the title [LinkedIn Audiences] Handle 401 errors from update audiences endpoint [STRATCONN-6520][LinkedIn Audiences] Handle 401 errors from update audiences endpoint Feb 2, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 InvalidAuthenticationError and 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

@joe-ayoub-segment joe-ayoub-segment merged commit 1039dff into main Feb 3, 2026
22 checks passed
@joe-ayoub-segment joe-ayoub-segment deleted the fix/linkedin-audiences-401-handling branch February 3, 2026 07:45
@joe-ayoub-segment
Copy link
Contributor

PR deployed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants