Repository navigation
nbo: read a token_file up front - #304
Open
multivac61 wants to merge 1 commit into
Open
multivac61 wants to merge 1 commit into
multivac61 wants to merge 1 commit into
Conversation
A token_command runs only when a request needs it, so reads go out anonymously and retry with the token only on a 401 or 403. The server answers an anonymous read of a private repository with an empty list or a 404 instead, so with only a token_command `nbo repo list` shows no private repositories and `nbo build list` reports them missing. A token kept in a file, such as a secret sops-nix or agenix decrypts, cannot prompt, so token_file is read up front and sent with every request like a static token. A token_file that cannot be read is an error rather than an anonymous client. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a
token_filehost setting fornbo. The file's first line is read when settings load and sent with every request, like a statictokenorNIXBOT_TOKEN.Why
Since #282,
token_commandruns only when a request needs it. Reads go out anonymously, and the token is fetched only after a 401 or 403. The server never answers a private repository that way. An anonymous/api/reposleaves private repositories out of the list, and/api/repos/<repo>/buildsreturns 404. So with only atoken_command,nbo repo listshows no private repositories, andnbo build listornbo schedule runreports them as not known, even though the token would see them.A token in a file, such as a secret sops-nix or agenix decrypts to
/run/secrets/…, cannot prompt. So it doesn't need #282's laziness, and reading it up front fixes private reads.token_commandkeeps its lazy behaviour for password managers.If a
token_filecan't be read,nboraises an error naming the path. It doesn't fall back to an anonymous client that quietly sees nothing.Testing
test_settings_token_filecovers reading the file,NIXBOT_TOKENtaking precedence, and the error for a missing file. All oftest_cli.pypasses, and ruff, mypy andnix fmtare clean.token_command = "cat /run/secrets/…"lists no private repositories, whiletoken_file = "/run/secrets/…"lists them and their builds.🤖 Generated with Claude Code