Summary
After switching projects with hookdeck project use, hookdeck whoami still reports the previously active project and organization, even though every other command (listen, connection list, etc.) correctly targets the newly selected project. This makes whoami misleading and undermines its main purpose — confirming which project you're operating on.
Observed on CLI v2.3.1.
Steps to reproduce
Given a user who belongs to projects in more than one org (e.g. Org A / Project and Org B / Project), currently active on Org A / Project:
$ hookdeck project use "Org B" "Project"
Successfully set active project to: Org B / Project
Saved to: ~/.config/hookdeck/config.toml
$ hookdeck whoami
Logged in as ... on project Project in organization Org A # ← still Org A
Meanwhile the switch did take effect for everything else:
$ hookdeck connection list # returns Org B / Project's connections
$ hookdeck listen 3030 my-src # dashboard link is team_id=<Org B project id>
The config file confirms the active project changed:
project_id = '<Org B project id>' # updated by `project use`
So the state is correct — only whoami's output is wrong.
Root cause
whoami resolves its display via ValidateAPIKey(), which calls clientForCLIAuthValidate() — a client copy that deliberately clears ProjectID so X-Team-ID / X-Project-ID are not sent:
https://github.com/hookdeck/hookdeck-cli/blob/main/pkg/hookdeck/auth.go#L136-L153
// clientForCLIAuthValidate returns a shallow copy of the client that omits
// X-Team-ID / X-Project-ID on requests. Stale project_id in config must not
// be sent to /cli-auth/validate — the server may prefer headers over the key's
// bound team and reject a valid key with 401.
func (c *Client) clientForCLIAuthValidate() *Client {
return &Client{
...
ProjectID: "",
...
}
}
Because the project header is omitted, GET /cli-auth/validate resolves the project/org from the API key's bound team alone, ignoring the config's active project_id. hookdeck project use updates project_id in config but keeps the same user-associated API key (see UseProject in pkg/cmd/project_use.go), so whoami reports whatever project the key is bound to — the original one — regardless of the current selection.
The header is cleared intentionally to avoid a stale project_id triggering a 401 (per the comment), so simply sending the header again is not the right fix — it would risk reintroducing that failure.
whoami prints these fields at pkg/cmd/whoami.go#L45-L51.
Suggested direction
whoami should report the config's active project (project_id), not the key's bound team. Options:
- After validating the key, resolve the active
project_id to its name/org via the project list (/teams, already used by project use) and display that.
- Or have
whoami display the config's project_id and look up its display name, keeping the key-only validate call purely for auth.
Either way the goal is that whoami and project use agree on the active project.
Impact
This surfaced while debugging a "CLI won't receive events" support report. whoami is the natural command to confirm you're on the right project, and here it actively points at the wrong one. For users who share a project name across orgs (e.g. multiple Default Projects), the mismatch is easy to miss and can send someone debugging the wrong project.
Related
Summary
After switching projects with
hookdeck project use,hookdeck whoamistill reports the previously active project and organization, even though every other command (listen,connection list, etc.) correctly targets the newly selected project. This makeswhoamimisleading and undermines its main purpose — confirming which project you're operating on.Observed on CLI
v2.3.1.Steps to reproduce
Given a user who belongs to projects in more than one org (e.g.
Org A / ProjectandOrg B / Project), currently active onOrg A / Project:Meanwhile the switch did take effect for everything else:
The config file confirms the active project changed:
So the state is correct — only
whoami's output is wrong.Root cause
whoamiresolves its display viaValidateAPIKey(), which callsclientForCLIAuthValidate()— a client copy that deliberately clearsProjectIDsoX-Team-ID/X-Project-IDare not sent:https://github.com/hookdeck/hookdeck-cli/blob/main/pkg/hookdeck/auth.go#L136-L153
Because the project header is omitted,
GET /cli-auth/validateresolves the project/org from the API key's bound team alone, ignoring the config's activeproject_id.hookdeck project useupdatesproject_idin config but keeps the same user-associated API key (seeUseProjectinpkg/cmd/project_use.go), sowhoamireports whatever project the key is bound to — the original one — regardless of the current selection.The header is cleared intentionally to avoid a stale
project_idtriggering a 401 (per the comment), so simply sending the header again is not the right fix — it would risk reintroducing that failure.whoamiprints these fields atpkg/cmd/whoami.go#L45-L51.Suggested direction
whoamishould report the config's active project (project_id), not the key's bound team. Options:project_idto its name/org via the project list (/teams, already used byproject use) and display that.whoamidisplay the config'sproject_idand look up its display name, keeping the key-only validate call purely for auth.Either way the goal is that
whoamiandproject useagree on the active project.Impact
This surfaced while debugging a "CLI won't receive events" support report.
whoamiis the natural command to confirm you're on the right project, and here it actively points at the wrong one. For users who share a project name across orgs (e.g. multipleDefault Projects), the mismatch is easy to miss and can send someone debugging the wrong project.Related