fix: fix: disinto init must be fully idempotent — safe to re-run on existing factory (#239) #264
No reviewers
Labels
No labels
action
backlog
blocked
bug-report
in-progress
prediction/actioned
prediction/dismissed
prediction/unreviewed
priority
tech-debt
underspecified
vision
No milestone
No project
No assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: disinto-admin/disinto#264
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/issue-239"
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?
Fixes #239
Changes
AI Review — Error\n\nReview failed.\n---\n
979e121AI Review — Error\n\nReview failed.\n---\n
979e121AI Review
Summary
The idempotency scaffolding is well-structured: compose file, cron, state files, ops repo namespace search, and collaborator re-application are all correct and safe to re-run. Two issues need addressing.
Issues
high
bin/disinto:880-896: Token cleanup relies on admin token listing of bot user tokens, but this path can silently fail.require_tokenin the mock returnsTrue(not a username), sotokens filtered by username == Truealways returns[]— the mock never actually exercises token deletion on re-run. More importantly, if the real Forgejo API rejects admin token auth onGET /api/v1/users/{username}/tokens(it's documented as requiring the user's own Basic Auth),existing_token_idssilently becomes"", no tokens are deleted, and the subsequentPOST /tokenswith the fixed namedisinto-{bot}-tokenreturns a 409 name collision —token=""—exit 1. The PR removes the timestamp-suffix fallback without ensuring the cleanup reliably works. The fix is straightforward: list and delete tokens usingbot_user:bot_pass(Basic Auth) instead of the admin token — we just reset that password and know it.low
bin/disinto:1068: Error message uses${actual_ops_slug}which is still""at the fallback failure point. Should reference${org_name}/${ops_name}instead.Smoke test gap
tests/smoke-init.shrunsdisinto initexactly once. The PR's stated purpose is safe re-runs, but no test calls init twice and verifies the second run exits 0. Combined with the mock not correctly simulating admin token listing (see above), the re-run scenario is entirely untested in CI.Verdict
REQUEST_CHANGES — Token cleanup path may silently fail in production, causing re-runs to error at token creation (the PR's core fix)
Reviewed at
979e121| AGENTS.mdAI Review: REQUEST_CHANGES — Token cleanup path may silently fail in production, causing re-runs to error at token creation (the PR's core fix)
AI Review — Error\n\nReview failed.\n---\n
a5c34a5AI Re-review (round 2)
Previous Findings
Token cleanup used admin token instead of bot Basic Auth → FIXED: Both list and delete now use
-u "${bot_user}:${bot_pass}". The mock'shandle_GET_users_username_tokensand newhandle_DELETE_users_username_tokens_token_idhandlers receive Basic Auth, sorequire_basic_authreturns the actual bot username and token filtering works correctly. The re-run token cleanup path is now correctly exercised.Error message used empty
${actual_ops_slug}→ FIXED: Error message now references${org_name}/${ops_name}directly.Smoke test didn't exercise re-run → FIXED: Added idempotency block that runs
disinto inita second time before state verification, giving the re-run scenario real CI coverage.Verdict
APPROVE — All three previous findings are correctly fixed; re-run path is now well-tested
Reviewed at
a5c34a5| Previous:979e121| AGENTS.mdAI Re-review (round 2): APPROVE — All three previous findings are correctly fixed; re-run path is now well-tested