(bug) Fix panic and missing partial-access fallback on /events endpoints#174
Merged
Merged
Conversation
- A ClusterRole missing the `events` permission crashed the server: `getEvents`/`getEvent` called `c.AbortWithError(401, err)` with `err` already guaranteed nil at that point, which panics inside gin's `Context.Error()`. - Unlike other list endpoints (`/capiclusters`, etc.), `/events` had no fallback for users who can't list all EventTriggers. It hard-failed instead of degrading to the subset the user can individually `get`. - Two more instances of the same nil-`err` `AbortWithError` pattern: `getProfile` and a debug cluster/profile lookup handler. All fixed the same way. - `getEventTriggers` now takes `canListAll`/`user` and filters results down to only EventTriggers the caller can individually access via `canGetEventTrigger`, mirroring `GetManagedCAPIClusters`'s existing pattern. - `getEvent` (single EventTrigger lookup) now falls back to `canGetEventTrigger` when the caller can't list all EventTriggers, matching the same fallback already used for ClusterProfile/Profile lookups.
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.
A ClusterRole missing the
eventspermission crashed the server:getEvents/getEventcalledc.AbortWithError(401, err)witherralready guaranteed nil at that point, which panics inside gin'sContext.Error().Unlike other list endpoints (
/capiclusters, etc.),/eventshad no fallback for users who can't list all EventTriggers. It hard-failed instead of degrading to the subset the user can individuallyget.Two more instances of the same nil-
errAbortWithErrorpattern:getProfileand a debug cluster/profile lookup handler. All fixed the same way.getEventTriggersnow takescanListAll/userand filters results down to only EventTriggers the caller can individually access viacanGetEventTrigger, mirroringGetManagedCAPIClusters's existing pattern.getEvent(single EventTrigger lookup) now falls back tocanGetEventTriggerwhen the caller can't list all EventTriggers, matching the same fallback already used for ClusterProfile/Profile lookups.