Skip to content

fix: forward plain-string headers to token fetch request - #1392

Draft
ankita10119 wants to merge 1 commit into
masterfrom
DXCDT-2250
Draft

fix: forward plain-string headers to token fetch request#1392
ankita10119 wants to merge 1 commit into
masterfrom
DXCDT-2250

Conversation

@ankita10119

Copy link
Copy Markdown
Contributor

Changes

What: Custom headers passed to ManagementClient (e.g. User-Agent) were not being forwarded to the internal POST /oauth/token token fetch request. They only appeared on subsequent Management API calls.

Why: TokenProvider constructed AuthenticationClient with headers: undefined, explicitly discarding all user-supplied headers. This was not intentional - the line was introduced in the initial v5 setup with no documented reason.

Fix: TokenProvider now extracts plain string headers from options.headers and forwards them to AuthenticationClient, so custom headers are consistently present on all outgoing requests including the token fetch.

Note: Only plain string header values are forwarded. Supplier functions (Fern's Record<string, Supplier<...>> type) are silently filtered out, as AuthenticationClient does not support async/dynamic header resolution.

No public API changes - this is a bug fix with no breaking changes.

References

  • Internal Slack report: custom User-Agent header not sent on first request when using clientId + clientSecret with ManagementClient

Testing

  • Added unit test: verifies plain string headers (e.g. User-Agent) are present on the POST /oauth/token request using nock's matchHeader
  • Added unit test: verifies supplier function headers are silently filtered without errors
  • All existing tests pass
  • This change adds unit test coverage
  • This change adds integration test coverage

Checklist

@ankita10119
ankita10119 requested a review from a team as a code owner August 19, 2026 08:58
@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.73%. Comparing base (5a85e25) to head (db2052a).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           master    #1392    +/-   ##
========================================
  Coverage   89.73%   89.73%            
========================================
  Files         441      441            
  Lines       20799    20802     +3     
  Branches     9809    10149   +340     
========================================
+ Hits        18663    18666     +3     
  Misses       2136     2136            
Flag Coverage Δ
alltests 89.73% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/management/wrapper/token-provider.ts 100.00% <100.00%> (ø)
🚀 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.

@ankita10119
ankita10119 marked this pull request as draft August 19, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant