bug: setup_forge's admin_token is a local variable, not exported — setup_ops_repo falls back to dev-bot token and fails with 403 #583
Labels
No labels
action
backlog
blocked
bug-report
cannot-reproduce
in-progress
in-triage
needs-triage
prediction/actioned
prediction/dismissed
prediction/unreviewed
priority
rejected
reproduced
tech-debt
underspecified
vision
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: disinto-admin/disinto#583
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
lib/forge-setup.sh(setup_forge) creates a fresh admin token for thedisinto-adminuser around line 237:This token is used within
setup_forge()for admin operations (creating bot .profile repos at lines 320, 346, 472, 479, 484). Butadmin_tokenis declared as a local variable. Whensetup_forgereturns, the local goes out of scope.Later in
bin/disinto init,setup_ops_repois called:setup_ops_repo(inlib/ops-setup.sh) referencesadmin_tokenwith a fallback:But
admin_tokenis not in scope (it was local tosetup_forge), so the fallback kicks in:FORGE_TOKENis dev-bot's token. dev-bot does not have admin-level permissions on the forgejo instance, so:disinto-admin/harb-opsexists uses dev-bot's token (also fails with 403 if dev-bot isn't a collaborator) → init thinks the repo doesn't existPOST /api/v1/orgs/disinto-admin/reposwith dev-bot's token → 403 (dev-bot isn't in disinto-admin org; alsodisinto-adminis a user, not an org, see sister issue)POST /api/v1/admin/users/disinto-admin/reposwith dev-bot's token → 403 (dev-bot is not a site admin)Init prints
Error: failed to create ops repo 'disinto-admin/harb-ops' (HTTP 403)and bails before setting up collaborators, branch protection, and migration.Reproduction
bin/disinto init <repo-url> --yessetup_forgesuccessfully, then fail at── Ops repo setup ──with HTTP 403Workaround
Export
admin_token(orHUMAN_TOKENif already in.env) before callingbin/disinto init:I used this workaround on harb-dev-box and init completed the ops repo setup successfully.
Fix
Option A — Export admin_token from
setup_forge:Option B — Pass admin_token as explicit arg to
setup_ops_repo:Option B is cleaner — explicit dependency, no reliance on env-var leakage.
Also consider: the
HUMAN_TOKENalready stored in.env(line 279 in setup_forge) is a suitable admin token for setup_ops_repo to use. Scripts that run after init (supervisor, agents) would benefit from a documented "which token for which operation" mapping.Context
Discovered while running
bin/disinto initas an idempotency experiment on harb-dev-box. Part of a cluster of ~9 init bugs found in that session.admin_tokenis a local variable, not exported — setup_ops_repo falls back to dev-bot token and fails with 403 (#583) #617admin_tokenis a local variable, not exported — setup_ops_repo falls back to dev-bot token and fails with 403 (#583) #617