Add auto repo registration feature - #42
Conversation
- Add new git provider's edit form - add new middleware for auto repo creation - separate parsing and verify/load workflow from loadForgejoContext, loadGitLabContext middlewares
Deploying proval-demo with
|
| Latest commit: |
1323219
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://3ddcb92c.proval-demo.pages.dev |
| Branch Preview URL: | https://feat-auto-repository-registr.proval-demo.pages.dev |
| const msg = e instanceof Error ? e.message : String(e); | ||
| if (msg.includes("NOT_FOUND") || msg.includes("not found")) { | ||
| return c.json({ error: "Access configuration not found" }, 404); | ||
| } |
There was a problem hiding this comment.
⚫️ [PROBLEM] Update handler returns 500 on duplicate baseUrl (create returns 409)
⚫ [PROBLEM] updateById on a provider/baseUrl that already hits the unique index (packages/db/src/schema.ts:96) throws a raw UNIQUE constraint error, which falls through to throw e here and produces an unhandled 500. The create handler at apps/api/src/api/access/access.controller.ts:52-55 already maps this exact case to 409, but update does not — and the edit form now lets users freely change baseUrl. Add the same UNIQUE→409 mapping:
if (msg.includes("UNIQUE") || msg.includes("unique")) {
return c.json({ error: "This access already exists" }, 409);
}|
|
||
| const personalAccessToken = decrypt(access.accessToken); | ||
| const gitlab = new GitLabProvider(access.baseUrl, personalAccessToken, projectId); | ||
| const isMaintainer = await gitlab.isConnectedAccountProjectMaintainer(); |
There was a problem hiding this comment.
🚨 [CRITICAL] Uncaught provider/decrypt errors in auto-create middleware become opaque 500s
🚨 [CRITICAL] The new auto-create branch performs external calls with no error handling: accessService.findForAutoCreate, decrypt(access.defaultWebhookSecret!), decrypt(access.accessToken), and await gitlab.isConnectedAccountProjectMaintainer() all propagate straight out of the middleware. GitLabProvider.fetchUserPermission rethrows non-404 provider errors (a transient GitLab outage or expired token: "GitLab permission lookup failed: …"), and decrypt throws on a bad ciphertext/key. Any of these kills the webhook request as an opaque 500 with no log, so auto-registration silently fails and deliveries are lost. Wrap this branch in try/catch and return 404/503 with logError, matching the pattern used in the API controllers. (Same pattern applies in verifyForgejoWebhook and in loadRepository's create step in apps/api/src/webhook/load-repository.middleware.ts.)
|
Hi, thanks for putting this together — this is a meaningful addition: access connections can now carry a full default config and let webhooks auto-register repositories on GitLab and Forgejo, with a matching client edit flow and provider docs. Solid, well-connected feature. OverviewSummary The schema/migration (0040) adds the default* config column suite to the provider access table; 🟢 Good points
Main Issues
Additional Notes
|
- Introduced `logWebhookRequest` middleware to log incoming webhook request URLs. - Integrated the new middleware into GitLab, Forgejo, and GitHub webhook routes.
Deploying proval with
|
| Latest commit: |
1323219
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://8181da6f.proval.pages.dev |
| Branch Preview URL: | https://feat-auto-repository-registr.proval.pages.dev |
| if (existing) { | ||
| const { repository } = existing; | ||
|
|
||
| const secret = decrypt(repository.webhookSecret).trim(); |
There was a problem hiding this comment.
⚫️ [PROBLEM] ⚫️ [PROBLEM] New 503 guard skips the existing-repository branch — its decrypt/DB throws stay unlogged 500s
The try/catch added in this push starts only at the auto-create branch (line 73). The existing-repository branch above it — the most common path, since it handles every delivery for an already-registered repository — still runs unguarded: fetchWebhookContextRow(projectId, "gitlab") at line 50 and decrypt(repository.webhookSecret) at line 54. The same gap remains in forgejo.middleware.ts (fetch at line 78, decrypt at line 82) and in load-repository.middleware.ts, whose tail decrypts repository.accessToken, modelProvider.apiKey, and access.accessToken (lines 134, 139-140) outside the new try that ends at line 123.
decrypt throws on an AES-GCM auth-tag failure (ENCRYPTION_KEY mismatch or rotation) and loadEncryptionKey throws when the key is unset or wrong-length (util/encrypt.ts:14-31, 55-66), and there is no app.onError anywhere in apps/api (grep found none), so these failures still surface as Hono's default 500 with no logError output — the exact opaque-failure mode this push just fixed one branch over, now on the sibling branch in the same request.
Could be wrong if you consider provider 5xx retries sufficient, but without a log line operators still have nothing to triage. Either extend the guard to each middleware's full body, or install a single webhookApp.onError in app.ts that logErrors and returns the same 503 shape — that would cover all of these call sites at once.
|
Hi — thanks for the quick follow-up. Both inline threads from the last review are addressed here, and the fixes are clean and well-scoped. OverviewSummary This push resolves the two flagged issues: the GitLab and Forgejo auto-create verify branches now wrap Good points
Main Issues
Additional Notes
The 409 and 503 fixes match what the prior threads asked for — with the existing-branch guard closed, the webhook chain would be fully covered. |
- add `webhookApp.onError()` - remove try/catch from middlewares(just throw)
|
Hi — nice follow-up: the per-middleware 503 guards are gone and replaced with a much tidier central handler. OverviewSummary This push trades the three duplicated try/catch blocks from the last round for a single Good points
Main IssuesNone. All verification passed. Additional Notes
|
|
@proval-0e6d07 Could you do a final review of the whole thing? |
|
Hi — final review done, covering the full 24-file change end to end (schema/migration, types, access service/controller, GitLab & Forgejo webhook chains, central error handling, client edit form, demo fixtures, docs). The two threads from the earlier rounds are resolved, and the central OverviewSummary Verified end to end: the three GitLab/Forgejo webhook chains now run Good points
Main Issues
Additional Notes
Everything else verified clean: edit-form save path sends With the migration FK decision made (issue 1) and the Forgejo gate aligned with the docs (issue 2), this is in good shape to merge. |
databases - add on delete set null action for 41 migration file
|
Hi — thanks for pushing this; it directly closes the biggest item from the last review. OverviewSummary This push adds I verified the key correctness points:
No Main Issues this round. One cosmetic note: the SQL file has no trailing newline ( I don't see anything blocking here; with the FK repaired, I'd consider this PR ready to merge. |
#16