-
Notifications
You must be signed in to change notification settings - Fork 63
SUMO-266317: Fix selectionType
handling for Role V2 to avoid MatchError
#798
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
selectionType
handling for Role V2 to avoid MatchError
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add test for this in resource_sumologic_role_v2_test.go
|
|
|
Issue
selectionType
for default roles.Read
function:json.Unmarshal
assigns the Go zero value (""
) toSelectionType
.d.Set("selection_type", roleV2.SelectionType)
with that empty string.TypeString
as unset and storesnull
in state.terraform apply
:d.Get("selection_type")
returns""
(SDK convertsnull → ""
).""
to the backend.selectionTypeToAvroSelectionType
throws ascala.MatchError
for empty string.Root Cause
omitempty
only affects JSON encoding, not decoding.selectionType
, Go’sjson.Unmarshal
sets it to the zero value""
.""
as unset for optional attributes and storesnull
.""
to the API instead of a valid value.Fix
Read
:SelectionType == ""
, default it to"All"
befored.Set
.null
and avoids perpetual diffs.Update
:SelectionType == ""
, set it to"All"
.MatchError
.