Skip to content

fix: handle legacy string-encoded customHeaders in ConnectionOptionsOAuth2#817

Closed
fern-api[bot] wants to merge 1 commit into
mainfrom
devin/1783434076-oauth2-legacy-custom-headers
Closed

fix: handle legacy string-encoded customHeaders in ConnectionOptionsOAuth2#817
fern-api[bot] wants to merge 1 commit into
mainfrom
devin/1783434076-oauth2-legacy-custom-headers

Conversation

@fern-api

@fern-api fern-api Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

🔧 Changes

ConnectionOptionsOAuth2.UnmarshalJSON fails with json: cannot unmarshal string into Go struct field ... of type map[string]string when the Management API returns customHeaders as a legacy JSON-encoded string instead of a map object, which crashes terraform-provider-auth0 on affected tenants.

This change makes the unmarshaler tolerant of the legacy format:

  • "customHeaders": {"key": "value"} (current format) — decoded into *ConnectionCustomHeadersOAuth2 as before.
  • "customHeaders": "<json-encoded-string>" (legacy format) — the field is left unset (nil) instead of returning an error, since the legacy value cannot be reliably decoded.
  • Any other non-null, non-string, non-object value still returns an unmarshal error.

Marshaling behavior is unchanged.

📚 References

Fixes #815

🔬 Testing

Added TestConnectionOptionsOAuth2UnmarshalCustomHeaders covering the map format, legacy string format, null, absent field, invalid type, and marshal round-trip. The legacy string case fails without this change with the exact error from #815 and passes with it. Full go test ./management/ passes.

📝 Checklist

  • All new/changed/fixed functionality is covered by tests (or N/A)
  • I have added documentation for all new/changed functionality (or N/A)

…sOAuth2 unmarshal

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@fern-api
fern-api Bot requested a review from a team as a code owner July 7, 2026 14:23
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.90%. Comparing base (ea264e2) to head (d128ad0).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #817   +/-   ##
=======================================
  Coverage   86.90%   86.90%           
=======================================
  Files         387      387           
  Lines      162844   162852    +8     
=======================================
+ Hits       141526   141534    +8     
  Misses      15990    15990           
  Partials     5328     5328           

☔ View full report in Codecov by Harness.
📢 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.

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.

ConnectionOptionsOAuth2 unmarshal fails on tenants with legacy string-encoded customHeaders

2 participants