fix(webhooks): gitea_webhooks create always fails with "Missing config option: content_type" #21

Closed
opened 2026-10-24 00:58:36 +00:00 by dsh · 1 comment
Owner

Symptom

Creating a repository webhook is impossible: the handler sends a config object without content_type, which Forgejo rejects before any webhook is created. The tool schema does not expose content_type, so there is no way to satisfy it.

Repro

gitea_webhooks {
  action: "create",
  owner: "ml-lab", repo: "tardits",
  url: "https://example.invalid/qa-probe",
  events: ["push"]
}
→ gitea_webhooks failed: Missing config option: content_type

A follow-up gitea_webhooks {action:"list", owner:"ml-lab", repo:"tardits"} returned No webhooks. — nothing was created.

Observed vs expected

  • Observed: create is unusable for the default type: "gitea" path.
  • Expected: create works with a sensible default (content_type: "json"), optionally overridable via a content_type parameter (json / form / multipart).

Root cause

lib/handlers/repos.js (webhook create):

return wrap(await client.createWebhook(owner, repo, {
  type: args.type || 'gitea',
  config: { url: args.url },
  events: args.events,
}))

Forgejo requires config.content_type for gitea webhooks.

Proposed fix

Add content_type: args.content_type || 'json' inside config, expose content_type in lib/tool-defs/repos.js as an enum, and validate it. Live test: create → list shows it → delete with confirm:true → list empty.

Acceptance: a create with only url + events succeeds and returns the webhook id; the lab repo is left clean.

Duplicate check

Searched issues for webhook (state all) → no existing issue.

Layer

dsh-gitea plugin/tool.

## Symptom Creating a repository webhook is impossible: the handler sends a `config` object without `content_type`, which Forgejo rejects before any webhook is created. The tool schema does not expose `content_type`, so there is no way to satisfy it. ## Repro ``` gitea_webhooks { action: "create", owner: "ml-lab", repo: "tardits", url: "https://example.invalid/qa-probe", events: ["push"] } → gitea_webhooks failed: Missing config option: content_type ``` A follow-up `gitea_webhooks {action:"list", owner:"ml-lab", repo:"tardits"}` returned `No webhooks.` — nothing was created. ## Observed vs expected - Observed: `create` is unusable for the default `type: "gitea"` path. - Expected: create works with a sensible default (`content_type: "json"`), optionally overridable via a `content_type` parameter (`json` / `form` / `multipart`). ## Root cause `lib/handlers/repos.js` (webhook create): ```js return wrap(await client.createWebhook(owner, repo, { type: args.type || 'gitea', config: { url: args.url }, events: args.events, })) ``` Forgejo requires `config.content_type` for `gitea` webhooks. ## Proposed fix Add `content_type: args.content_type || 'json'` inside `config`, expose `content_type` in `lib/tool-defs/repos.js` as an enum, and validate it. Live test: create → list shows it → delete with `confirm:true` → list empty. Acceptance: a create with only `url` + `events` succeeds and returns the webhook id; the lab repo is left clean. ## Duplicate check Searched issues for `webhook` (state all) → no existing issue. ## Layer dsh-gitea plugin/tool.
Author
Owner

Fixed in 281eade (PR #40).

Webhook create now sends config.content_type (json default, json|form|multipart accepted and validated) and requires url. Added a formatter so the result is Webhook #1 created (type gitea). and list rows are readable.

Live on ml-lab/tardits: create with only url + events → Webhook #1 created (type gitea).; list → one; delete confirm:true → list → No webhooks. (lab left clean).

Tests: test/qa-defaults.test.mjs.

Fixed in `281eade` (PR #40). Webhook create now sends `config.content_type` (`json` default, `json|form|multipart` accepted and validated) and requires `url`. Added a formatter so the result is `Webhook #1 created (type gitea).` and list rows are readable. Live on `ml-lab/tardits`: create with only `url` + `events` → `Webhook #1 created (type gitea).`; list → one; delete `confirm:true` → list → `No webhooks.` (lab left clean). Tests: `test/qa-defaults.test.mjs`.
dsh closed this issue 2026-10-24 01:16:37 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
dsh-plugins/dsh-gitea#21
No description provided.