Skip to content

Conversation

Emyrk
Copy link
Member

@Emyrk Emyrk commented Apr 13, 2023

sql.ErrNoRows was hiding actual errors. This makes dbauthz return actual unauthorized errors, and the api just needs to check both sql.ErrNoRows and dbauthz.IsUnauthorized to return a 404.

Fixes: #6774

@Emyrk Emyrk marked this pull request as ready for review April 13, 2023 15:55
@Emyrk Emyrk requested review from johnstcn and kylecarbs April 13, 2023 15:55
@@ -224,7 +224,7 @@ func (api *API) provisionerJobResources(rw http.ResponseWriter, r *http.Request,
}

// nolint:gocritic // GetWorkspaceAppsByAgentIDs is a system function.
apps, err := api.Database.GetWorkspaceAppsByAgentIDs(ctx, resourceAgentIDs)
apps, err := api.Database.GetWorkspaceAppsByAgentIDs(dbauthz.AsSystemRestricted(ctx), resourceAgentIDs)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooops, I missed this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The sql.ErrNoRows hid it ☹️

@Emyrk Emyrk merged commit 38e5b96 into main Apr 13, 2023
@Emyrk Emyrk deleted the stevenmasley/rbac_error branch April 13, 2023 18:06
@github-actions github-actions bot locked and limited conversation to collaborators Apr 13, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Fix DBAuthz return sql.ErrNoRows
2 participants