forgejo role: fix §6 guard so per-repo Actions is actually enabled #6
No reviewers
Labels
No labels
needs-info
needs-triage
ready-for-agent
ready-for-human
wontfix
needs-info
needs-triage
ready-for-agent
ready-for-human
review/merge-ready
review/needs-fix
review/needs-human
review/needs-review
wayfinder:grilling
wayfinder:map
wayfinder:prototype
wayfinder:research
wayfinder:task
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
olympus/infra-forge!6
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/actions-guard-repo-list"
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?
Follow-up to the prod apply of #5. The per-repo Actions flag (
has_actions) did not get enabled:repo_unithas no row of type 10 forpit/infra-forgeand noansible-has-actions-*token was ever minted.Root cause
community.postgresql'slist_to_pg_array(module_utils/postgres.py) converts a listnamed_argbystr()-ing it and stripping only the brackets, soforgejo_actions_repos(['pit/infra-forge']) is sent as the literal{'pit/infra-forge'}. Its first element is the single-quoted 17-byte string'pit/infra-forge', which never equals the DB's 15-bytepit/infra-forge.= ANY(%(repos)s)therefore matches nothing, the guard reports "no repo lacks Actions", and the whole enablement block is skipped on every run.Verified live on prod guest 141 (collection v4.2.0): the literal form returns the row (and
eq_literal=true), the list form returns 0 rows, element hex27...27(quotes included).Fix
Pass a scalar —
forgejo_actions_repos | join(',')— and split it back into an array in SQL withstring_to_array(%(repos)s, ','). Repo slugs areowner/name, so,is not a legal character in one.unit_typeis a scalar int and was never affected.After applying: the guard returns
pit/infra-forge, the block mints the transient token, PATCHeshas_actions: true, and deletes the token.Refs #3.
The guard query's `= ANY(%(repos)s)` never matched: community.postgresql's list_to_pg_array (module_utils/postgres.py) str()s a list named_arg and only strips the brackets, so `forgejo_actions_repos` (['pit/infra-forge']) was sent as the literal {'pit/infra-forge'} whose element is the single-quoted 17-byte "'pit/infra-forge'" -- no row matches. The guard therefore reported "no repo lacks Actions", the enablement block was skipped on every run, and has_actions stayed false on pit/infra-forge (verified live on prod guest 141, collection v4.2.0: literal form returns the repo, the list form returns zero rows). Pass a scalar (comma-joined) and split it back into an array in SQL. Repo slugs are owner/name, so ',' is not a legal character in one. Verified: the guard now returns the repo and the block is entered.Two-axis review findings, addressed:
Standards — all three were judgement calls; all now addressed
,written in two places that must agree): hoisted toforgejo_actions_repos_sepin role defaults.join(forgejo_actions_repos_sep)andstring_to_array(..., %(sep)s)now read the same value.reposholding a scalar): renamedrepos_csv.Spec
bad,slugcould be split and silently skipped, exactly like the bug being fixed. Added anassertthat fails the run before the guard if any slug contains the separator. Verified both directions against prod: real config →All assertions passed; injectedbad,slug→ fails with the intended message.has_actionsflips and whether a second run is clean is observable only by running the playbook against the guest. Tracked as the post-merge step on #3, not claimable from a code change.list_to_pg_arrayatmodule_utils/postgres.py:529(str(elem).strip('[]')). No test harness exists in this repo for a live-DB query, so the comment is the record.Not done, deliberately: the issue's closing smoke test (
push a trivial workflow, observe a green run) and the Prod second-run. Both are runtime observations on the live guest, not code changes; both remain open on #3.Both found by rehearsing the §6 fix on a fresh PRE guest (142), which is the first time the enablement block ever executed -- the guard bug had always skipped it. 1. Cleanup 401'd and left a live admin token behind. The delete called DELETE /users/{u}/tokens/{name}, the *admin* route: reqBasicOrRevProxyAuth rejects token auth there ("auth method not allowed", v15), and v15 has no self-service /user/tokens/{name} either (404, verified live). The run failed at the last step and the 40-hex admin token stayed in the UI -- the exact leftover minting-per-run exists to avoid. Delete the access_token row directly instead, over the postgres connection the probes already use. 2. First task failed on a fresh guest: the template's apt index is stale and `apt install git` 404s on a version it still names (libcurl3t64-gnutls ...deb13u4). Added one cache refresh at the top of §1 (cache_valid_time 3600, so re-runs inside the hour skip the network) and dropped the lone update_cache from the postgres task. Verified end-to-end on a destroyed-and-recreated PRE guest: full run green (29 ok / 0 failed), §6 flips has_actions False->True, the transient token is deleted (0 leftover rows), and a second run is 0 changed.8c504e12dfto3cd28c59e0Tested on PRE (fresh LXC 142, destroyed and recreated). Answering the question directly: the earlier verification was check-mode + read-only DB probes only — that was not a real PRE run, and it missed two bugs because the enablement block had never actually executed. A proper rehearsal found them.
Verified on PRE, end-to-end
ok=29 changed=22 failed=0).PATCH has_actions: true→has_actionsflipsFalse→True(confirmed via the API).changed=0(story 12 satisfied for this section).Two further bugs the rehearsal exposed (both fixed on this branch)
DELETE /users/{u}/tokens/{name}is the admin route and rejects token auth (auth method not allowed); v15 has no self-service/user/tokens/{name}either (404). The last task of the block failed and the 40-hex admin token stayed inaccess_token— the exact leftover per-run minting is meant to prevent. Now theaccess_tokenrow is deleted directly over the postgres connection the probes already use. Verified: 0 leftoveransible-has-actions-*rows after a run.apt install git404s on a version it still names (libcurl3t64-gnutls ...deb13u4). Added oneupdate_cacherefresh at the top of §1 (cache_valid_time: 3600).Still not done (runtime, not code): the issue's closing smoke test — push a trivial
.forgejo/workflows/file and observe a green run with logs in the UI — has not been run. It remains the last gate on #3 after merge.PRE guest 142 has been destroyed and the parked rig files restored to the
forgejo-prebranch.