fix: feat: lib/vault.sh — helper for agents to create vault PRs on ops repo (#75) #81
No reviewers
Labels
No labels
action
backlog
blocked
in-progress
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: johba/disinto#81
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/issue-75"
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 #75
Changes
5cabe9d3c6to353b3d68d5353b3d68d5toa54e238282AI Review
Summary
The
pr_find_by_branch()extension to accept an optionalapi_urlis clean and well-placed. The idempotency logic, branch-via-REST approach, and overall structure are good. Two bugs prevent the feature from actually working, plus a third design inconsistency.Issues
critical
lib/vault.sh:155:pr_create()was NOT updated to accept anapi_urlparameter likepr_find_by_branch()was. It still hardcodes${FORGE_API}(the disinto repo). Every vault PR will be created on the disinto repo instead of the ops repo. The fix is to add an optionalapi_urlparameter topr_create()(mirroring the change made topr_find_by_branch()) and passops_apiwhen calling it. Note: the 409 fallback insidepr_create()atlib/pr-lifecycle.sh:95also callspr_find_by_branch "$branch"withoutapi_url, so it would look up the wrong repo too — that path needs the same fix.bug
lib/vault.sh:43:_vault_ops_api()encodes hyphens as%2Dviased 's/-/%2D/g'. Hyphens are unreserved characters in RFC 3986 and must NOT be percent-encoded. IfFORGE_OPS_REPOcontains a hyphen (e.g.johba/ops-infra), every curl call built from this URL will 404. Remove the sed encoding entirely — just use${FORGE_OPS_REPO}directly.design inconsistency
lib/vault.sh:92-98: The AGENTS.md entry for vault.sh states it \u201cuses agent\u2019s own token (not shared) so approval workflow respects individual identities.\u201d However, sourcingvault/vault-env.shunconditionally overwritesFORGE_TOKENwithFORGE_VAULT_TOKEN(vault-env.sh line 9:FORGE_TOKEN="${FORGE_VAULT_TOKEN:-${FORGE_TOKEN}}"). IfFORGE_VAULT_TOKENis set, all subsequent API calls — including PR creation — use vault-bot\u2019s identity, not the calling agent\u2019s. Either the code or the documentation is wrong. If vault-bot identity is intentional, update AGENTS.md. If per-agent identity is required, loadvalidate_vault_actionwithout sourcing vault-env.sh\u2019s token-switching logic (e.g., source only the function definition, or save/restoreFORGE_TOKENaround the source).Minor
lib/vault.sh:121:-sf -s—-sis already included in-sf; the standalone-sis redundant.lib/vault.sh:120-125: Mixing-f(exit non-zero on HTTP \u2265 400) with-w "%{http_code}"produces garbled output on 404 (curl writes \u201c404\u201d then exits non-zero,|| echo "0"appends \u201c0\u201d, yielding \u201c4040\u201d). It works by accident since the result is never \u201c200\u201d in the error case. Drop-fand rely solely on-w "%{http_code}"for status detection.Verdict
REQUEST_CHANGES — pr_create() still uses FORGE_API (disinto repo) — vault PRs land on the wrong repository; also _vault_ops_api() incorrectly encodes hyphens, breaking all ops-repo API calls
Reviewed at
a54e238| AGENTS.mdAI Review: REQUEST_CHANGES — pr_create() still uses FORGE_API (disinto repo) — vault PRs land on the wrong repository; also _vault_ops_api() incorrectly encodes hyphens, breaking all ops-repo API calls
a54e238282to657b8aff36AI Re-review (round 2)
Previous Findings
pr_create()used wrong API → FIXED:pr_create()now accepts optional[api_url](5th param), the call site passes"$PRIMARY_BRANCH" "$ops_api", and the 409 fallback forwards"$api_url"topr_find_by_branch._vault_ops_api()encoded hyphens → FIXED: sed removed, now simplyprintf '%s' "${FORGE_URL}/api/v1/repos/${FORGE_OPS_REPO}".FORGE_TOKENoverwritten by sourcing vault-env.sh → FIXED: token saved to_saved_forge_tokenbefore source, restored immediately after (both in the error and success path). AGENTS.md updated to document the save/restore behaviour.-sflag → FIXED.-fmixed with-w "%{http_code}"→ FIXED: changed tocurl -s -o /dev/null -w "%{http_code}".Verdict
APPROVE — all three findings addressed correctly; nits fixed too
Reviewed at
657b8af| Previous:a54e238| AGENTS.mdAI Re-review (round 2): APPROVE — all three findings addressed correctly; nits fixed too