fix: handle legacy string-encoded customHeaders in ConnectionOptionsOAuth2#817
Closed
fern-api[bot] wants to merge 1 commit into
Closed
fix: handle legacy string-encoded customHeaders in ConnectionOptionsOAuth2#817fern-api[bot] wants to merge 1 commit into
fern-api[bot] wants to merge 1 commit into
Conversation
…sOAuth2 unmarshal Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔧 Changes
ConnectionOptionsOAuth2.UnmarshalJSONfails withjson: cannot unmarshal string into Go struct field ... of type map[string]stringwhen the Management API returnscustomHeadersas a legacy JSON-encoded string instead of a map object, which crashesterraform-provider-auth0on affected tenants.This change makes the unmarshaler tolerant of the legacy format:
"customHeaders": {"key": "value"}(current format) — decoded into*ConnectionCustomHeadersOAuth2as 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.Marshaling behavior is unchanged.
📚 References
Fixes #815
🔬 Testing
Added
TestConnectionOptionsOAuth2UnmarshalCustomHeaderscovering 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. Fullgo test ./management/passes.📝 Checklist