Skip to content

Add bl whoami to print your user ID - #50

Open
scottcrawford03 wants to merge 1 commit into
block:mainfrom
scottcrawford03:scrawford/bl-whoami
Open

scottcrawford03 wants to merge 1 commit into
block:mainfrom
scottcrawford03:scrawford/bl-whoami

Conversation

@scottcrawford03

Copy link
Copy Markdown
Contributor

Why

Apps Platform identifies people by a user-* ID, which shows up as an app's owner and in publisher lists. You also need it when someone adds you as a publisher. bl auth status doesn't show it, so today the only way to find your own ID is to read the owner of an app you already own.

What

Add a top-level bl whoami command:

  • bl whoami prints the ID by itself, for example user-RC1BSbHMpBkDJm-o.
  • bl whoami --json prints {"user_id": "...", "environment": "..."}.
  • If the control plane returns no caller, it fails with caller_missing.

The README has a short "Your user ID" section.

How

It reads caller from the control plane's current-user discovery (GET /v1/apps/me?limit=1). The control plane sets caller from the verified principal, never from request parameters. The command uses the same control_plane_args, host allowlist, session or Blox proxy authentication and error mapping as bl apps. limit=1 keeps the response small, since the command reads only caller.

I chose this route over the owned listing (/v1/agent/apps?scope=owned, which also returns caller). The owned listing enumerates the fleet and took 2–3s in bb-block production, while /v1/apps/me answered in about 0.5s once warm.

Risk

Low. This adds a new read-only command and leaves existing commands alone. In forwarded-workspace mode, /v1/apps/me returns 503 when the control plane has no membership provider configured. The command would then show the standard Apps HTTP error. It works in bb-block production. I haven't checked bb-public.

Testing

  • just check passes: fmt, clippy, and all lib and e2e tests.
  • New process tests cover text and JSON output, the exact request path, and missing or blank caller. The root --describe-commands test now expects whoami.
  • I ran the local binary against bb-block production (compose-ctrl.block.builderlab.xyz). It printed the expected user-* ID, and --json returned environment: production.

`bl auth status` shows the session and workspace but not the `user-*` ID
that Apps Platform uses for app owners and publishers, so finding your
own ID meant reading the `owner` of an app you already own.

`bl whoami` reads `caller` from the control plane's current-user
discovery (`GET /v1/apps/me?limit=1`) with the same control plane and
authentication as `bl apps`, including the Blox proxy. It prints the ID
alone, or `{"user_id", "environment"}` with --json, and fails with
`caller_missing` if the response has no caller.

Co-authored-by: octopus <822c70215c3e7c911200b21e6489f79227c744a53fd35fc71254c84229a8b7ca@buzz.block.builderlab.xyz>
@scottcrawford03
scottcrawford03 requested a review from a team as a code owner November 16, 2026 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants