Skip to content

[v13] Fix panic on nil value in getPresetRoles()#35462

Merged
timothyb89 merged 6 commits intobranch/v13from
bot/backport-35458-branch/v13
Dec 8, 2023
Merged

[v13] Fix panic on nil value in getPresetRoles()#35462
timothyb89 merged 6 commits intobranch/v13from
bot/backport-35458-branch/v13

Conversation

@timothyb89
Copy link
Copy Markdown
Contributor

@timothyb89 timothyb89 commented Dec 7, 2023

Backport #35458 to branch/v13

changelog: Fixed panic on potential nil value when requesting /webapi/presetroles

timothyb89 and others added 2 commits December 7, 2023 02:23
This fixes a panic when attempting to fetch `/webapi/presetroles` as
`ui.NewRoles()` is (reasonably) not nil safe. `GetPresetRoles()` can
return nil entries if corresponding features are disabled, so this
tweaks `GetPresetRoles()` to filter out nil entries.

This endpoint is only used for Cloud features (email invites at
onboarding, specifically) and currently all features are enabled for
Cloud users, so the only internal use is minimally impacted.

The other use of `GetPresetRoles()`, `createPresetRoles()`, already
checks for nil entries. It's behavior is unchanged.
Co-authored-by: Zac Bergquist <zac.bergquist@goteleport.com>
Not all CI jobs seem to run on the go version that added `slices`,
so this unrolls the implementation for v13. v14 and master both use
the `slices` impl.
@timothyb89 timothyb89 enabled auto-merge December 8, 2023 00:04
@timothyb89 timothyb89 added this pull request to the merge queue Dec 8, 2023
Merged via the queue into branch/v13 with commit f284263 Dec 8, 2023
@timothyb89 timothyb89 deleted the bot/backport-35458-branch/v13 branch December 8, 2023 00:40
@camscale camscale mentioned this pull request Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants