feat(forgejo): make webhook triggers traceable and read write access from the payload #13
No reviewers
Labels
No labels
Agent
Ignore
Agent
In Progress
Agent
Planned
Agent
Planning
Agent
Ready
Agent
Triage
Compat
Breaking
Kind
Bug
Kind
Documentation
Kind
Enhancement
Kind
Feature
Kind
Security
Kind
Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
lucas/omp-deck!13
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/forgejo-comment-driven"
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?
Three changes to the Forgejo comment pipeline.
Delivery log (
0a4caa6). Every request toPOST /api/forgejo/webhooknow becomes one row in a newforgejo_deliverieslog (migration 012). The log is capped at the newest 200 rows, because unauthenticated callers can add rows. Each row records the outcome, the HTTP status returned, the reason or error, the delivery and event headers, the body size, and, for verified payloads only, the repo, number, action and sender. Accepted and duplicate rows link to theirforgejo_triggersrow, and duplicates link to the original trigger.GET /api/forgejo/triggersis replaced byGET /api/forgejo/deliveries. Settings → Forgejo → Recent deliveries now lists the 20 newest entries, each with an outcome badge, HTTP status, detail, delivery id, and the linked trigger's status and session link. Responses to Forgejo are unchanged.Write access from the signed payload (
2eace98). The dispatcher used to ask Forgejo's collaborator-permission endpoint, which Forgejo answers only for site or repo admins, so every trigger failed with a 403 when the agent account was a plain write collaborator. Write access now comes from the payload'srepository.permissions, which Forgejo computes for the sender and the receiver has already authenticated by HMAC. The agent account no longer needs admin rights on the repository.Trigger lookup tools (
ec9fa93). Failure comments name a trigger id that nothing in the deck could resolve. Interactive deck sessions now getdeck_forgejo_trigger_get(the trigger row, the triggering comment's URL and body from the stored payload, and its linked delivery-log rows) anddeck_forgejo_trigger_list(recent triggers for a repo, optionally one issue/PR), so a failure can be investigated by asking the agent.Decisions
X-Forgejo-Deliverycheck afterJSON.parsechanges one edge case. A signed request with both a missing delivery id and an unparseable body now gets400 invalid json bodyinstead of400 missing X-Forgejo-Delivery. Every single-fault response is unchanged.verified: falseandrepo: null. No duplicate tests were added.insertForgejoTriggerhits a dedupe conflict but cannot find the conflicting row, it throws instead of returning an emptyexistingId. The receiver records that asstore_failedwith a 500.too_large,unsupported_content_typeandnot_configuredrows takebodyBytesfrom theContent-Lengthheader (null if it's missing), since the body is never read for those.repository.permissionsdescribes the webhook's sender, who is the editor on an edit. A comment edited by someone other than its author is therefore dropped (edited by someone other than its author), and a payload without permissions fails closed (author lacks write access (unknown)).session-policy.ts, and a trigger's reason can contain local paths or provider internals that must stay off Forgejo.Verification
bun run typecheck(protocol, server, web): passes.bun test src/routes-forgejo-webhook.test.ts src/db/forgejo-deliveries.test.ts src/forgejo/dispatcher.test.ts: 29 pass, 0 fail (run on0a4caa6).bun test src/bridge/forgejo-trigger-tools.test.ts src/db/forgejo-deliveries.test.ts: 6 pass, 0 fail.bun testatec9fa93(all three commits): 709 pass, 0 fail across 47 files.bun run --filter '@omp-deck/web' build: succeeds.feat(forgejo): log every webhook delivery in Recent deliveriesto feat(forgejo): make webhook triggers traceable and read write access from the payload