-
Notifications
You must be signed in to change notification settings - Fork 887
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: remove unnecessary user lookup in agent API calls #17934
Conversation
e0f806f
to
b1f8370
Compare
There was a problem hiding this 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.
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 like 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. |
Change-Id: I3b6e7581134e2374b364ee059e3b18ece3d98b41 Signed-off-by: Thomas Kosiewski <tk@coder.com>
b1f8370
to
840c0db
Compare
Yup! I imagine there are a few other places that are redundant now with the view |
Merge activity
|
/cherry-pick release/2.22 |
1 similar comment
/cherry-pick release/2.22 |
Use workspace.OwnerUsername instead of fetching the owner
This PR optimizes the agent API by using the
workspace.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 Kosiewski tk@coder.com