Repository navigation
feat(cli): add tigris env to hand credentials to other tools - #321
katieschilling wants to merge 1 commit into
Conversation
The CLI reads AWS_* and TIGRIS_STORAGE_* variables but never wrote them, so going from "logged in with tigris" to "boto3 works" meant copying five values out of the docs by hand. `tigris env` prints them: eval "$(tigris env)" tigris env --format dotenv > .env tigris env --shell fish | source tigris env --tigris # TIGRIS_STORAGE_* names tigris env --json Only the assignments go to stdout, so the output is safe to eval or redirect; anything for a human goes to stderr. This is the convention `gh auth token`, `fly auth token` and direnv's `.envrc` rely on. OAuth sessions carry a token that only the CLI can use, so `env` explains how to mint an access key in that case instead of printing something that would not work. Quoting is per shell (POSIX, fish, PowerShell) and dotenv values are quoted only when they need to be; renderEnv and envVars are pure and covered by unit tests. README regenerated from specs; AUTHENTICATION.md gains a section; changeset included. Assisted-by: Claude Fable 5.1 via Claude Code Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RxFeqmYcQs5JbydZeCzw2j
|
| onFailure: 'Failed to get user information' | ||
| onAlreadyDone: "Not authenticated\nRun \"tigris login\" to authenticate" | ||
| # env | ||
| - name: env |
There was a problem hiding this comment.
The command description says “the Tigris SDKs,” which violates the repository directive to use “Tigris” without the definite article. Use “Tigris SDKs” here and in the matching authentication guide and changeset wording; regenerating the README should update its generated occurrences. This repository requirement must be satisfied before merging.
Rule Used: Don't use the definite article 'the' before 'Tigris' in documentation (e.g., write 'Tigris' not 'the Tigris'). (source)
Learned From
tigrisdata/tigris-os-docs#262
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 37cc105. Configure here.
| 'The current session has no access key to export (OAuth sessions carry a token that only the CLI can use). ' + | ||
| 'Create one with "tigris access-keys create <name>", save it with "tigris configure", then run "tigris env" again.' | ||
| ); | ||
| } |
There was a problem hiding this comment.
OAuth session blocks configured key export
High Severity
env resolves credentials through getStorageConfig(), which prefers an active OAuth session over keys saved by tigris configure. OAuth config always has empty accessKeyId and secretAccessKey, so the documented recovery path — create a key, configure, then env — still fails after configure while the OAuth session remains active.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 37cc105. Configure here.
| const tigris = getOption<boolean>(options, ['tigris']) === true; | ||
|
|
||
| const config = await getStorageConfig(); | ||
|
|
There was a problem hiding this comment.
Auto-login contaminates eval stdout
Medium Severity
Unauthenticated TTY runs call getStorageConfig(), which starts interactive auto-login and writes progress to stdout. eval "$(tigris env)" and redirects then capture that text. Auto-login also typically produces an OAuth session, which env cannot export, so the user is prompted to log in only to fail afterward.
Reviewed by Cursor Bugbot for commit 37cc105. Configure here.
|
Follow-up for the
(or |
| export AWS_REGION='auto' | ||
| ``` | ||
|
|
||
| This is the same convention other CLIs use to move a credential from their own store into the shell: `gh auth token` prints the GitHub token for `GH_TOKEN`, `fly auth token` prints the Fly.io token for `FLY_API_TOKEN`, and direnv's whole model is an `.envrc` of exports that the shell evaluates on `cd`. |
|
|
||
| `tigris env` needs an access key. OAuth sessions carry a token that only the CLI can use, so from an OAuth session create a key first and save it: | ||
|
|
||
| ```sh |
There was a problem hiding this comment.
Could these steps be simplified further
| /** | ||
| * `tigris env`: hand the CLI's credentials to everything else. | ||
| * | ||
| * The CLI reads AWS_* and TIGRIS_STORAGE_* variables, but until now nothing |
There was a problem hiding this comment.
Could you ask the agent to be concise when writing code comments? There are several unnecessary comments here


What
A new top-level command,
tigris env, that prints the active credentials as the environment variables the AWS SDKs, the AWS CLI and the Tigris SDKs read:Default output:
Why
The CLI already reads
AWS_*andTIGRIS_STORAGE_*(seeAUTHENTICATION.mdandresolveAuthMethod), but nothing ever wrote them. Going from "I rantigris login" to "my app / boto3 / the AWS CLI talks to Tigris" meant copying five values out of the docs by hand, which is exactly the step that stalls a migration. Theinit --agentrecipe even spells out the five-variable mapping for agents to transcribe; this makes it one command.It's the same convention other CLIs use to move a credential from their own store into the shell:
gh auth tokenprints the GitHub token forGH_TOKEN(export GH_TOKEN=$(gh auth token)).fly auth tokenprints the Fly.io token forFLY_API_TOKEN..envrcof exports that the shell evaluates oncd.Design notes
eval "$(tigris env)"and> .envare safe. The existingmessagesmachinery already writes failures to stderr.'\''), fish single quotes (\'), PowerShell single quotes (''). dotenv values are bare unless they contain something that needs double quotes.renderEnvandenvVarsare pure functions with unit tests for each.envfails with the three commands that get you there (access-keys create→configure→env). Every other auth method (AWS profile, env vars, credentials login, configured) works, and a custom endpoint fromconfigure --endpointis preserved.README.mdis regenerated fromspecs.yaml(pnpm run updatedocs);AUTHENTICATION.mdgains a "Handing Credentials to Other Tools" section; changeset included (minor).Testing
pnpm exec vitest run(1015 tests, 40 files) andtsc --noEmitpass;biome lintclean.eval "$(…)"round-trip, a secret containing',--tigris, and the unauthenticated path (exit 2, nothing on stdout).Follow-ups (not in this PR)
init --agentrecipe could say "runtigris env --format dotenv" instead of listing the mapping.🤖 Generated with Claude Code
https://claude.ai/code/session_01RxFeqmYcQs5JbydZeCzw2j
Note
Medium Risk
The command intentionally writes secrets to stdout for eval/redirect; quoting is tested and OAuth export is blocked, but mishandling output still exposes credentials.
Overview
Adds
tigris env, a command that prints the active access-key credentials as environment variables so AWS SDKs, the AWS CLI, and Tigris SDKs can use the same login without manual copy-paste.Output goes only to stdout (assignments/errors on stderr), supporting
eval "$(tigris env)", dotenv files, and shell (sh, fish, PowerShell) via--format/--shell.--tigrisswitches toTIGRIS_STORAGE_*names; JSON is available for scripts. Implementation lives inenv.ts(envVars,renderEnv) wired throughspecs.yaml, with unit tests for variable sets and quoting.OAuth-only sessions are rejected with guidance to create/configure an access key first. Docs (
AUTHENTICATION.md,README.md) and a minor changeset document the workflow.Reviewed by Cursor Bugbot for commit 37cc105. Bugbot is set up for automated code reviews on this repo. Configure here.