Repository navigation
fix: avoid panic parsing array-shaped REST error bodies - #1183
Merged
Merged
Conversation
the single-object branch guards env.Error != nil but the array branch did
not, so a non-2xx body like [{"code":400}] dereferenced a nil error and
panicked the provider. guard envs[0].Error != nil on the array branch too
Kirdock
approved these changes
Jul 21, 2026
Kirdock
left a comment
Collaborator
There was a problem hiding this comment.
Hi, thanks for your contribution!
LGTM
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.
Why this PR?
any non-2xx classic-API response whose body is a JSON array without an
errorfield (e.g.[{"code":400}]) panics the provider with a nil-pointer dereferenceWhat has changed?
EnvelopeandunmarshalErrornow guardenvs[0].Error != nilon the array branch, like the existing single-object branch already doesHow does it do it?
adds
&& envs[0].Error != nilto the array-branch condition indynatrace/rest/error.goanddynatrace/rest/request.go, so a shape-drifted array body falls through instead of dereferencing nilHow is it tested?
added a table test in
error_test.gofor array/object bodies with and without theerrorfield; it panics on the old code and passes on the newHow does it affect users?
a malformed or array-shaped error response no longer crashes the provider mid-operation
Issue: N/A