Branch-planner authorized integration JWT rejected: token is malformed / access token does not exist #2
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Symptom
Since 2026-11-16 23:48Z, every Forgejo API call made with the branch-planner Authorized Integration auth is rejected. Observed in the
automationnamespace workflow pods (create-k8s-resources-in-repo*, add-deploykey + generate-manifests steps), which authenticate through our fork's forgejo provider using thetokenFilemechanism (internal/git/provider/options.go:152-162, reads the projected token per call).Forgejo error responses:
Both signatures in the same response means Forgejo tried the authorized-integration JWT path (content is not a JWT at all, 0/2 segments) and the access-token path (sha no longer on the server).
Context
tofuandtofu-planner.flux-system-tofu-controller-branch-planner) is running but has its own open comment-id bug; this issue is specifically the JWT being rejected, which currently also breaks the automation namespace workflows.Suspects, in order
token(or an emptytokenFiletarget): projected SA token not mounted, mounted empty, or wrong path.tofu-plannerAuthorized Integration expects after the Forgejo 17 migration (audience/token_endpoint re-saved with different values).Repro / verify checklist
tokenvstokenFile) without dumping values.head -c 20starts witheyJ(a JWT).tofu-plannerauthorized integration's token audience and regenerate the integration token if needed.create-k8s-resources-in-repoworkflow; the RBAC gap in the same pods (workflowtaskresults, fixed separately in flux-clusters) should be merged first so the workflow can report results.Search keywords: authorized integration jwt token malformed segments branch planner automation workflows.
Root cause
This was not a tofu-controller bug. The
tokenFilepath in the fork works as designed.create-k8s-resources-in-repo*, stepsadd-deploykeyandcreate-pr) are plaincurlcontainers. They sent a static PAT fromautomation/automation-workflow-merge-secret(keytoken). Forgejo no longer had that PAT. It tried every auth method on the string and rejected it, so the error listed the JWT parse failure next to "access token does not exist". The[sha: ...]in that message is the raw token the client sent, not a hash. It has been redacted from the handoff doc and should be treated as leaked.vault-backend(mini's in-cluster Vault). The Vault was sealed after the mini power cycle, so all 49 ExternalSecrets on that store were stale. It has been unsealed, the store revalidated, and 48 of 49 synced.forgejo/vault-examplehas an older, unrelated ownership conflict.u:263:..., no auth errors in its logs.Fix
forgejo-identity): new machine userargo-automation. It has write onlab/automationandlab/dev-apps-source, and an admin teamargo-automationondev-applications(adding deploy keys needs repo admin). Its Authorized Integration was created with the Forgejo CLI: issuerhttps://kubernetes.default.svc.cluster.local,sub=system:serviceaccount:automation:automation-kubetenantsetup, scopewrite:repository, audienceu:264:5d9f72bb-b8ce-4542-9c3c-167de30002ad.create-k8s-repo-resources-in-repoWorkflowTemplate now mounts a projected SA token with that audience and callscurl --fail-with-body. The PAT is no longer used. Nothing syncs this repo to mini (the old Argo CD annotation is stale), so the template was applied withkubectl apply.Verified
A workflow from the template with entrypoint
add-deploykeyagainstdev-applications/gofantasyauthenticated through the integration and reached Forgejo's duplicate-key check (422 "This key has already been added"), which needs repo admin. The smoke workflow was deleted afterwards.Follow-ups
tokenkey from Vault pathautomation-workflow-merge-secret. The template no longer reads it.lab/automationto mini. That needs a Flux source or a decision to apply by hand.