fix: disinto init repo creation silently fails — wrong API endpoint for user namespace #164

Closed
opened 2026-04-03 05:51:47 +00:00 by dev-bot · 0 comments
Collaborator

Problem

bin/disinto init reports "Repo: johba/harb created on Forgejo" but the repo is never actually created. The Forgejo API returns zero repos after init completes.

Root cause

In bin/disinto, the setup_forge() function around lines 883-901 tries two paths to create the repo, both of which fail silently:

  1. Create org johba (POST /api/v1/orgs) — fails with user already exists because johba is a regular user, not an org
  2. Create repo under org (POST /api/v1/orgs/johba/repos) — fails because the org does not exist
  3. Fallback: create under user (POST /api/v1/users/johba/repos) — returns 405 Method Not Allowed because /api/v1/users/{username}/repos is a GET-only endpoint in Forgejo

Both the org-path failure and the user-path failure are swallowed by || true, so the script continues to the collaborators loop and prints "created on Forgejo" even though nothing was created.

Expected behavior

The repo should actually be created. The correct Forgejo API endpoint for creating a repo in a user namespace is one of:

  • POST /api/v1/user/repos (with the owning user's token, i.e. HUMAN_TOKEN)
  • POST /api/v1/admin/users/johba/repos (with an admin token)

The script should also fail loudly if neither path succeeds — not silently continue.

Steps to reproduce

# Clean slate
docker compose down -v && rm -f .env
# Init
bin/disinto init https://codeberg.org/johba/harb --branch master --yes
# Check — returns empty
source .env && curl -sf -H "Authorization: token $FORGE_TOKEN" http://localhost:3000/api/v1/repos/search?limit=10 | jq .data

Files

  • bin/disintosetup_forge(), lines ~883-901 (repo creation block)
## Problem `bin/disinto init` reports "Repo: johba/harb created on Forgejo" but the repo is never actually created. The Forgejo API returns zero repos after init completes. ## Root cause In `bin/disinto`, the `setup_forge()` function around lines 883-901 tries two paths to create the repo, both of which fail silently: 1. **Create org `johba`** (`POST /api/v1/orgs`) — fails with `user already exists` because `johba` is a regular user, not an org 2. **Create repo under org** (`POST /api/v1/orgs/johba/repos`) — fails because the org does not exist 3. **Fallback: create under user** (`POST /api/v1/users/johba/repos`) — returns **405 Method Not Allowed** because `/api/v1/users/{username}/repos` is a GET-only endpoint in Forgejo Both the org-path failure and the user-path failure are swallowed by `|| true`, so the script continues to the collaborators loop and prints "created on Forgejo" even though nothing was created. ## Expected behavior The repo should actually be created. The correct Forgejo API endpoint for creating a repo in a user namespace is one of: - `POST /api/v1/user/repos` (with the owning user's token, i.e. HUMAN_TOKEN) - `POST /api/v1/admin/users/johba/repos` (with an admin token) The script should also fail loudly if neither path succeeds — not silently continue. ## Steps to reproduce ```bash # Clean slate docker compose down -v && rm -f .env # Init bin/disinto init https://codeberg.org/johba/harb --branch master --yes # Check — returns empty source .env && curl -sf -H "Authorization: token $FORGE_TOKEN" http://localhost:3000/api/v1/repos/search?limit=10 | jq .data ``` ## Files - `bin/disinto` — `setup_forge()`, lines ~883-901 (repo creation block)
dev-bot added the
backlog
label 2026-04-03 05:51:47 +00:00
dev-bot self-assigned this 2026-04-03 05:51:55 +00:00
dev-bot added
in-progress
and removed
backlog
labels 2026-04-03 05:51:55 +00:00
dev-qwen removed the
in-progress
label 2026-04-03 05:52:39 +00:00
dev-bot removed their assignment 2026-04-03 06:00:31 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
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#164
No description provided.