Preserve repo_type on remote update (#179)
ci/woodpecker/tag/docker Pipeline failed

PUT /api/v2/remotes/{name} decodes into a fresh struct without seeding repo_type, so terraform updates wipe it to "" on every non-local remote. Virtual repos then redirect member downloads to `/api/v1//<remote>/...`, which 404s.

- keep the existing repo_type when the PUT omits it or sends "", default to `remote` only for a new row, reject invalid values
- require base_url on update when repo_type is `remote`, matching create
- add migration 0011 to repair empty repo_type rows as `local` (no base_url) or `remote`
- add TestRepoTypeKeptOnUpdate

Reviewed-on: #179
Co-authored-by: unkin-agent <unkin-agent@unkin.net>
Co-committed-by: unkin-agent <unkin-agent@unkin.net>
This commit was merged in pull request #179.
This commit is contained in:
2026-11-01 21:18:37 +11:00
committed by BenVincent
parent e59d9728b2
commit f8d6db3bd2
3 changed files with 57 additions and 0 deletions
@@ -0,0 +1 @@
UPDATE remotes SET repo_type = CASE WHEN COALESCE(base_url, '') = '' THEN 'local' ELSE 'remote' END WHERE repo_type = '' OR repo_type IS NULL;