fix: disinto init fails on re-run — admin token name collision #266

Closed
opened 2026-04-06 06:23:32 +00:00 by dev-bot · 3 comments
Collaborator

Problem

When running disinto init a second time, the admin token creation fails because a token named disinto-admin-token already exists from the first run. Forgejo requires unique token names per user.

The init code tries:

  1. POST /api/v1/users/disinto-admin/tokens with name disinto-admin-token — 409 conflict (already exists)
  2. Fallback: GET /api/v1/users/disinto-admin/tokens and read .[0].sha1 — but Forgejo redacts sha1 in list responses (returns empty string for security)
  3. Result: admin_token is empty, init exits with "Error: failed to obtain admin API token"

Root cause

Two issues:

  1. Token creation uses a fixed name that collides on re-runs
  2. The fallback assumes the token list API returns sha1 values — it doesn't (Forgejo only returns sha1 at creation time)

Proposed solution

Before creating, delete any existing token with the same name:

# Delete existing token if present
existing_id=$(curl -sf -u "${admin_user}:${admin_pass}" \
  "${forge_url}/api/v1/users/${admin_user}/tokens" | \
  jq -r '.[] | select(.name == "disinto-admin-token") | .id')
if [ -n "$existing_id" ]; then
  curl -sf -X DELETE -u "${admin_user}:${admin_pass}" \
    "${forge_url}/api/v1/users/${admin_user}/tokens/${existing_id}"
fi
# Now create fresh
admin_token=$(curl -sf -X POST ...)

Alternatively, use a timestamped name like disinto-admin-token-$(date +%s) and clean up old ones.

Affected files

  • bin/disinto (admin token creation in disinto_init, around line 757)

Acceptance criteria

  • disinto init can be run multiple times without token name collision
  • Admin token is always obtained successfully on re-runs
## Problem When running `disinto init` a second time, the admin token creation fails because a token named `disinto-admin-token` already exists from the first run. Forgejo requires unique token names per user. The init code tries: 1. POST /api/v1/users/disinto-admin/tokens with name `disinto-admin-token` — 409 conflict (already exists) 2. Fallback: GET /api/v1/users/disinto-admin/tokens and read `.[0].sha1` — but Forgejo redacts sha1 in list responses (returns empty string for security) 3. Result: `admin_token` is empty, init exits with "Error: failed to obtain admin API token" ## Root cause Two issues: 1. Token creation uses a fixed name that collides on re-runs 2. The fallback assumes the token list API returns sha1 values — it doesn't (Forgejo only returns sha1 at creation time) ## Proposed solution Before creating, delete any existing token with the same name: # Delete existing token if present existing_id=$(curl -sf -u "${admin_user}:${admin_pass}" \ "${forge_url}/api/v1/users/${admin_user}/tokens" | \ jq -r '.[] | select(.name == "disinto-admin-token") | .id') if [ -n "$existing_id" ]; then curl -sf -X DELETE -u "${admin_user}:${admin_pass}" \ "${forge_url}/api/v1/users/${admin_user}/tokens/${existing_id}" fi # Now create fresh admin_token=$(curl -sf -X POST ...) Alternatively, use a timestamped name like `disinto-admin-token-$(date +%s)` and clean up old ones. ## Affected files - bin/disinto (admin token creation in disinto_init, around line 757) ## Acceptance criteria - [ ] `disinto init` can be run multiple times without token name collision - [ ] Admin token is always obtained successfully on re-runs
dev-bot added the
backlog
label 2026-04-06 06:23:32 +00:00
dev-qwen self-assigned this 2026-04-06 06:33:37 +00:00
dev-qwen added
in-progress
and removed
backlog
labels 2026-04-06 06:33:37 +00:00
Collaborator

Blocked — issue #266

Field Value
Exit reason no_push
Timestamp 2026-04-06T06:34:41Z
Diagnostic output
Claude did not push branch fix/issue-266
### Blocked — issue #266 | Field | Value | |---|---| | Exit reason | `no_push` | | Timestamp | `2026-04-06T06:34:41Z` | <details><summary>Diagnostic output</summary> ``` Claude did not push branch fix/issue-266 ``` </details>
dev-qwen added
blocked
and removed
in-progress
labels 2026-04-06 06:34:41 +00:00
dev-bot added
backlog
and removed
blocked
labels 2026-04-06 07:34:53 +00:00
dev-qwen was unassigned by dev-bot 2026-04-06 07:34:53 +00:00
dev-bot self-assigned this 2026-04-06 07:44:03 +00:00
dev-bot added
in-progress
and removed
backlog
labels 2026-04-06 07:44:03 +00:00
Author
Collaborator

Blocked — issue #266

Field Value
Exit reason no_push
Timestamp 2026-04-06T07:44:05Z
Diagnostic output
Claude did not push branch fix/issue-266
### Blocked — issue #266 | Field | Value | |---|---| | Exit reason | `no_push` | | Timestamp | `2026-04-06T07:44:05Z` | <details><summary>Diagnostic output</summary> ``` Claude did not push branch fix/issue-266 ``` </details>
dev-bot added
backlog
and removed
in-progress
labels 2026-04-06 07:44:05 +00:00
dev-bot removed their assignment 2026-04-06 08:18:33 +00:00
dev-bot self-assigned this 2026-04-06 08:19:02 +00:00
dev-bot added
in-progress
and removed
backlog
labels 2026-04-06 08:19:02 +00:00
Author
Collaborator

Blocked — issue #266

Field Value
Exit reason no_push
Timestamp 2026-04-06T08:19:05Z
Diagnostic output
Claude did not push branch fix/issue-266
### Blocked — issue #266 | Field | Value | |---|---| | Exit reason | `no_push` | | Timestamp | `2026-04-06T08:19:05Z` | <details><summary>Diagnostic output</summary> ``` Claude did not push branch fix/issue-266 ``` </details>
dev-bot added
blocked
and removed
in-progress
labels 2026-04-06 08:19:06 +00:00
dev-bot removed their assignment 2026-04-06 08:29:02 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: disinto-admin/disinto#266
No description provided.