Skip to content

[v14] Fix panic on nil value in getPresetRoles()#35463

Merged
zmb3 merged 2 commits intobranch/v14from
bot/backport-35458-branch/v14
Dec 7, 2023
Merged

[v14] Fix panic on nil value in getPresetRoles()#35463
zmb3 merged 2 commits intobranch/v14from
bot/backport-35458-branch/v14

Conversation

@timothyb89
Copy link
Copy Markdown
Contributor

Backport #35458 to branch/v14

changelog: Fix 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>
@zmb3 zmb3 added this pull request to the merge queue Dec 7, 2023
Merged via the queue into branch/v14 with commit d691fb4 Dec 7, 2023
@zmb3 zmb3 deleted the bot/backport-35458-branch/v14 branch December 7, 2023 05:11
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