Repository navigation
feat(mr): expose viewer identity and permissions - #706
Conversation
There was a problem hiding this comment.
The latest commit fixes the earlier output nit: the text output now reads User: <id> (<name>) and leaves out the name when it is empty. I found no other bugs. A human should still look, because this adds a command to the list of commands an agent-turn token may run.
What was reviewed:
- The turn-token allowlist in
login(pkg/cmd/mr/mr.go).viewergoes throughauthenticateUserand thenResolveTurnReadAuth, the same pathview,listandthreadsuse, and sandbox_test.go covers it. - viewer.go: the check for older servers (Unimplemented, or Unknown with a "route not found" message), the response checks (missing org, missing user, non-USER actor, org mismatch), and text output sanitized through
printable(). - The proto additions are new field numbers and new messages only, so the wire format stays compatible. I did not compare the regenerated pb.go and connect code against a fresh
buf generaterun.
Extended reasoning...
The change adds a hidden, read-only depot mr viewer command, a GetViewer RPC, and new proto fields for viewer identity and permissions, mostly in generated code. The security-sensitive part is in pkg/cmd/mr/mr.go: the list of commands a Dispatch agent-turn token may run now includes viewer. That makes the read-only scope of turn tokens wider. The command only returns the caller's own identity and uses the read-only turn auth, so it looks intended, but widening a credential's scope is a decision a human should confirm. The PR also depends on an API rollout happening before this CLI is released.


Clients need the authenticated Depot user and the actions allowed on a merge request. Add
depot mr viewer [--org] [--json], which works outside a checkout, and preserve the API's viewer and permission fields indepot mr view --json.The command supports member agent-turn reads, validates the returned organization and identity, sanitizes text output, and reports a clear error when the server does not yet support viewer identity. Existing commands retain their behavior.
Validation: full
go test ./..., CLI build, and focused golangci-lint passed. Tests cover viewer output, credential routing, mismatched identity, older APIs and permission JSON. Verified the unsupported-server error against the live API.Rollout: deploy depot/api#7083 before releasing this CLI. Tracked in DEP-8717.
Created with GPT-6 Astra in Codex.
Catch up on this pull request in Depot
Note
Low Risk
Read-only CLI and proto additions with validation tests; behavior changes are additive and gated on new API fields.
Overview
Adds
depot mr viewerto resolve the authenticated Depot user (and org) via a newGetViewerRPC—usable without a repo checkout, with--json, sanitized text output, graceful errors on older servers, and org mismatch checks.Extends the merge-request API surface with
MergeRequestActor.display_name,viewerandviewer_permissionsonGetMergeRequestResponse, and theGetViewer/MergeRequestViewerPermissionsmessages; wires the Connect client and allows agent turn tokens forvieweralongside existing read-onlyview,list, andthreadscommands.Reviewed by Cursor Bugbot for commit 52871bc. Bugbot is set up for automated code reviews on this repo. Configure here.