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

fix: remove unnecessary user lookup in agent API calls#17934

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

Conversation

ThomasK33
Copy link
Member

@ThomasK33ThomasK33 commentedMay 20, 2025
edited
Loading

Use workspace.OwnerUsername instead of fetching the owner

This PR optimizes the agent API by using theworkspace.OwnerUsername field directly instead of making an additional database query to fetch the owner's username. The change removes the need to callGetUserByID in the manifest API and workspace agent RPC endpoints.

An issue arose when the agent token was scoped without access to user data (api_key_scope = "no_user_data"), causing the agent to fail to fetch the manifest due to an RBAC issue.

Change-Id: I3b6e7581134e2374b364ee059e3b18ece3d98b41
Signed-off-by: Thomas Kosiewskitk@coder.com

@ThomasK33ThomasK33 self-assigned thisMay 20, 2025
@ThomasK33Graphite App
Copy link
MemberAuthor

This stack of pull requests is managed byGraphite. Learn more aboutstacking.

@ThomasK33ThomasK33force-pushed thethomask33/05-20-fix_remove_unnecessary_user_lookup_in_agent_api_calls branch frome0f806f tob1f8370CompareMay 20, 2025 11:12
@ThomasK33ThomasK33 marked this pull request as ready for reviewMay 20, 2025 11:35
Copy link
Contributor

@dannykoppingdannykopping left a comment

Choose a reason for hiding this comment

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

LGTM, although I'm not sure how far this approach of restricting agent access with RBAC will take us.

@Emyrk
Copy link
Member

We've had this issue that we need username, template name, workspace name, etc. So we fetch the original object for that 1 or two fields, but the caller might not have access to this related object.

We have created some views likeworkspace_build_with_user to just join in these fields, and not require the RBAC to the original user.

The views are awkward to manage, but solves the same issue you are hitting. Since agent keys can only hit a small subset of routes, I think we can manage its implications.

ThomasK33 reacted with thumbs up emoji

@ThomasK33Graphite App
Copy link
MemberAuthor

ThomasK33 commentedMay 20, 2025
edited
Loading

Oh, that's a great point. I just checked the SQL queries for the call ofGetWorkspaceByID, and it uses theworkspaces_expanded (view) (query) under the hood.

So the information is already getting joined as you suggested. I guess those follow-up calls were genuinely redundant.

Emyrk reacted with thumbs up emoji

Change-Id: I3b6e7581134e2374b364ee059e3b18ece3d98b41Signed-off-by: Thomas Kosiewski <tk@coder.com>
@ThomasK33ThomasK33force-pushed thethomask33/05-20-fix_remove_unnecessary_user_lookup_in_agent_api_calls branch fromb1f8370 to840c0dbCompareMay 20, 2025 14:55
@Emyrk
Copy link
Member

So the information is already getting joined as you suggested. I guess those follow-up calls were genuinely redundant.

Yup! I imagine there are a few other places that are redundant now with the view

@ThomasK33ThomasK33 merged commit93f17bc intomainMay 20, 2025
37 checks passed
@ThomasK33Graphite App
Copy link
MemberAuthor

Merge activity

@ThomasK33ThomasK33 deleted the thomask33/05-20-fix_remove_unnecessary_user_lookup_in_agent_api_calls branchMay 20, 2025 15:07
@github-actionsgithub-actionsbot locked and limited conversation to collaboratorsMay 20, 2025
@bpmct
Copy link
Member

/cherry-pick release/2.22

1 similar comment
@bpmct
Copy link
Member

/cherry-pick release/2.22

Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@dannykoppingdannykoppingdannykopping approved these changes

@EmyrkEmyrkEmyrk approved these changes

Assignees

@ThomasK33ThomasK33

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@ThomasK33@Emyrk@bpmct@dannykopping

[8]ページ先頭

©2009-2025 Movatter.jp