Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

chore: reorder prebuilt workspace authorization logic#18506

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ssncferreira merged 6 commits intomainfromssncferreira/chore-prebuilt-authz-order
Jun 24, 2025

Conversation

ssncferreira
Copy link
Contributor

Description

Follow-up from PR#18333
Related with:#18333 (comment)

This changes the authorization logic to first try the normal workspace authorization check, and only if the resource is a prebuilt workspace, fall back to the prebuilt workspace authorization check. Since prebuilt workspaces are a subset of workspaces, the normal workspace check is more likely to succeed. This is a small optimization to reduce unnecessary prebuilt authorization calls.

@ssncferreirassncferreiraforce-pushed thessncferreira/chore-prebuilt-authz-order branch from0e5bcd0 toa4b2e8dCompareJune 23, 2025 16:25
@ssncferreirassncferreira marked this pull request as ready for reviewJune 23, 2025 16:27
@johnstcnjohnstcn self-requested a reviewJune 23, 2025 17:27
if prebuiltErr = q.authorizeContext(ctx, action, workspace.AsPrebuild()); prebuiltErr == nil {
return nil
}
return xerrors.Errorf("authorize context as prebuild: %w", errors.Join(workspaceErr, prebuiltErr))
Copy link
Member

Choose a reason for hiding this comment

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

I see what you are doing, but idk how much more value it is to show both errors.

Maybe just show theprebuildErr, since that is a subset. Your call in the end.xerrors.As andxerrors.Is does handle joined errors. It takes the first one it looks like.

Copy link
ContributorAuthor

@ssncferreirassncferreiraJun 24, 2025
edited
Loading

Choose a reason for hiding this comment

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

Good point 🤔 I wanted to keep theworkspaceErr to make it explicit that both the workspace and prebuilt authorization paths failed. I think this could be useful for debugging and for quickly identifying that the error comes from this special-case handling.
Instead of usingerrors.Join, maybe I could make it more readable by updating the message to something like:

return xerrors.Errorf("authorize context failed for workspace (%v) and prebuilt (%w)", workspaceErr, prebuiltErr)

Wdyt? Addressed in1f0e33a

Copy link
Member

@EmyrkEmyrkJun 24, 2025
edited
Loading

Choose a reason for hiding this comment

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

That works. In production, the%v just translates torbac: forbidden

errUnauthorized = "rbac: forbidden"

func (eUnauthorizedError)Error()string {
ifflag.Lookup("test.v")!=nil {
returne.longError()
}
returnerrUnauthorized
}

So the message is like:

authorize context failed for workspace (rbac: forbidden) and prebuilt (rbac: forbidden)

(assuming no error chains, which is probably there)
That all looks good to me imo 👍

@ssncferreirassncferreira requested a review fromEmyrkJune 24, 2025 12:57
@ssncferreirassncferreira merged commitf44969b intomainJun 24, 2025
34 checks passed
@ssncferreirassncferreira deleted the ssncferreira/chore-prebuilt-authz-order branchJune 24, 2025 15:33
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsJun 24, 2025
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@johnstcnjohnstcnjohnstcn approved these changes

@EmyrkEmyrkEmyrk approved these changes

Assignees

@ssncferreirassncferreira

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@ssncferreira@johnstcn@Emyrk

[8]ページ先頭

©2009-2025 Movatter.jp