Skip to content
Merged
26 changes: 26 additions & 0 deletions .changeset/34098-webhook-method-get-retired.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
'@objectstack/spec': minor
'@objectstack/plugin-webhooks': minor
---

fix(spec,plugin-webhooks)!: a webhook can no longer be saved with method `GET`, and a stored GET webhook is parked with a visible reason instead of failing silently

Clause-②: no (narrowing)
Metadata-protocol: narrowed
Skills-docs: none — `git grep` of `skills/` finds no webhook `method` value taught anywhere, so no page names `GET` as a webhook method.

<!-- adr-0087: registered webhook-method-get-retired -->

**BREAKING** for a webhook authored with `method: 'GET'`. Every webhook delivery sends the event envelope as its request body, and a GET request carries none, so no GET webhook ever delivered an event: the outbox sent the body, the HTTP client refused a GET with a body, and the delivery retried until dead. `GET` is removed from both authoring surfaces.

What moves (each line FROM → TO):

- `WebhookSchema.method` (`@objectstack/spec/automation`, a declared webhook in `defineStack({ webhooks })`): FROM `GET` / `POST` / `PUT` / `PATCH` / `DELETE` TO `POST` / `PUT` / `PATCH` / `DELETE` (default `POST`, unchanged). `method: 'GET'` fails parse with a prescription naming the four methods; any other unknown method keeps zod's own message. A declared GET webhook already in a registry is skipped with the existing "declared webhook failed validation — not dispatched" warning.
- the `sys_webhook` `method` select (`@objectstack/plugin-webhooks`, Setup and the data API): FROM five options TO four; an insert or an update with `method: 'get'` FROM stored TO refused 400 `VALIDATION_FAILED`. The `options.get` translation leaves every locale bundle.
- a `sys_webhook` row already stored with `get`: FROM retried until dead on every event (and, from the outbox's bodyless-GET refusal on, a lost-event log line and no delivery row) TO parked — each event it matches is written to `sys_http_delivery` as a `dead` row with 0 attempts, no signature and a reason that names the method and the fix, said once at `error`; nothing is sent and the row cannot be redelivered.

The fix: set the webhook's `method` to the one the endpoint accepts a body on — `POST` (the default), `PUT`, `PATCH` or `DELETE`. The parked row re-arms at the next periodic cache refresh. A receiver that only answers GET cannot take a webhook.

No conversion is made, at load, at save or by a migration (ADR-0087 D3, entry `webhook-method-get-retired`): there is no lossless one, because converting GET to another method would start sending a different request to an endpoint its administrator configured for GET. A stored row's method is left exactly as stored.

Unchanged: a `POST` / `PUT` / `PATCH` / `DELETE` webhook delivers byte-identically; `HEAD` was never a webhook method on either surface.
20 changes: 19 additions & 1 deletion content/docs/automation/webhooks.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ returned in full by `GET /api/v1/data/sys_webhook`.
| `object_name` | text | Short object name whose record events fire this webhook. |
| `triggers` | select | Multi-select of `create` / `update` / `delete` plus the opt-in bulk pair `bulk_update` / `bulk_delete` ([see below](#bulk-writes-bulk_update-and-bulk_delete)), stored as an array (the enqueuer also accepts a legacy comma-separated string). |
| `url` | text | External endpoint that receives the POST. |
| `method` | select | HTTP method — one of `GET` / `POST` / `PUT` / `PATCH` / `DELETE`. Default `POST`. |
| `method` | select | HTTP method — one of `POST` / `PUT` / `PATCH` / `DELETE`. Default `POST`. No `GET`: every delivery carries the event as its body ([see below](#stored-get-webhooks-are-parked)). |
| `description` | textarea | Free-text description. |
| `active` | boolean | Inactive webhooks are skipped by the dispatcher. Default `true`. |
| `definition_json` | textarea | Serialised `Webhook` JSON (`WebhookSchema` from `@objectstack/spec/automation`) — the per-attempt `timeoutMs` and the rest of the authored envelope. **Not** the signing secret and **not** the custom headers: each has its own encrypted column below. |
Expand Down Expand Up @@ -237,6 +237,24 @@ row, or move the values into their encrypted columns yourself. Never type a toke
ages it out.
</Callout>

### Stored GET webhooks are parked

`GET` was removed from the `method` select and from `WebhookSchema.method`:
every delivery sends the event envelope as its request body and a GET request
carries none, so no GET webhook ever delivered an event. Saving a webhook with
`method: 'get'` — an insert or an update — is now refused
(`VALIDATION_FAILED` / `400`), and a declared webhook with `method: 'GET'`
fails `WebhookSchema` parse with the fix in the message.

A `sys_webhook` row already stored with `get` keeps loading, but it is
**parked**: nothing is sent, and each record change it matches is written to
`sys_http_delivery` as a `dead` row with 0 attempts whose `error` names the
method and the fix. Such a row cannot be redelivered. The stored method is
never rewritten to another one — sending a POST to an endpoint configured for
GET would be a different request. To bring the webhook back, edit it and set
the method to `POST`, `PUT`, `PATCH` or `DELETE`, whichever the endpoint
accepts a body on; it re-arms at the next periodic cache refresh.

### 3.2 `sys_http_delivery`

The outbox + audit. One row per delivery. Persisted **before** any HTTP
Expand Down
2 changes: 1 addition & 1 deletion content/docs/references/automation/webhook.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const result = WebhookSchema.parse(data);
| **object** | `string` | optional | Object whose record events (create/update/delete, bulk_update/bulk_delete) trigger this webhook |
| **triggers** | `Enum<'create' \| 'update' \| 'delete' \| 'bulk_update' \| 'bulk_delete'>[]` | optional | Events that trigger execution |
| **url** | `string` | ✅ | External webhook endpoint URL |
| **method** | `Enum<'GET' \| 'POST' \| 'PUT' \| 'PATCH' \| 'DELETE'>` | optional (default: `"POST"`) | HTTP method |
| **method** | `Enum<'POST' \| 'PUT' \| 'PATCH' \| 'DELETE'>` | optional (default: `"POST"`) | HTTP method |
| **headers** | `Record<string, string>` | optional | Custom HTTP headers |
| **timeoutMs** | `integer` | optional (default: `30000`) | Request timeout in milliseconds |
| **secret** | `string` | optional | Signing secret for HMAC signature verification |
Expand Down
124 changes: 117 additions & 7 deletions packages/plugins/plugin-webhooks/src/auto-enqueuer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,48 @@ const CUSTOM_HEADERS_CREDENTIAL: DropReason = {
ratherThan: 'delivered without the headers it was authored with',
};

/**
* The HTTP methods a webhook may no longer deliver with, upper-cased.
*
* `GET` left both authoring surfaces (the spec's `WebhookSchema.method` and the
* `sys_webhook` `method` select — ADR-0049 enforce-or-remove): every delivery
* sends the event envelope as its request body and a GET carries none, so no
* GET webhook ever delivered. A row stored with `get` before the option left
* still loads, and is PARKED here rather than dispatched.
*/
const RETIRED_WEBHOOK_METHODS: ReadonlySet<string> = new Set(['GET']);

/**
* The ADR-0112 pair a retired-method park carries: the standard-catalog
* member for "this row content is not acceptable", judged at delivery — the
* pair `webhook-legacy-cleartext.ts` carries on its own delivery door. (The
* save door refusing the same value is the engine's record validator, which
* answers with its own code.) A standard-catalog code needs no ledger row.
*/
const RETIRED_METHOD_PARK_CODE = 'VALIDATION_ERROR';
const RETIRED_METHOD_PARK_STATUS = 400;

/**
* [#8069 park path] The reason a subscription whose stored method is retired
* is parked with, or `undefined` for a deliverable method. It names the method
* and the fix, and says the method is left as stored: converting it would
* start sending another method to an endpoint the administrator configured
* for GET, so no conversion is made, here or anywhere.
*/
function retiredMethodParkReason(name: string, method: string): string | undefined {
if (!RETIRED_WEBHOOK_METHODS.has(method)) return undefined;
return (
`[${RETIRED_METHOD_PARK_CODE}/${RETIRED_METHOD_PARK_STATUS}] webhook '${name}' is stored with HTTP method `
+ `${method}, which a webhook can no longer use: every delivery sends the event as its request body and a `
+ `${method} request carries none, so this event was NOT delivered — recorded here rather than sent. `
+ 'This row was never sent and cannot be redelivered. The stored method is left exactly as it is: it is '
+ 'never converted, because sending another method to an endpoint configured for '
+ `${method} would be a different request. Fix: edit the webhook and set its method to POST, PUT, PATCH `
+ 'or DELETE, whichever the endpoint accepts a body on; the subscription re-arms at the next periodic '
+ 'refresh, and later events are delivered normally.'
);
}

/**
* Optional logger interface (subset of console / kernel logger).
*/
Expand Down Expand Up @@ -333,6 +375,13 @@ export class AutoEnqueuer {
* is deleted and re-created reports again.
*/
private readonly organizationRefusalReported = new Set<string>();
/**
* Webhook ids whose retired-method park has been said out loud
* ({@link reportRetiredMethod}) — the #8022 say-once shape: once per
* parked subscription, again after its method is fixed and it breaks
* again. Pruned on refresh with the two ledgers above.
*/
private readonly retiredMethodReported = new Set<string>();
/** [ADR-0131 D2/D6] The declared-webhook reader, when the host binds one. */
private readonly declared?: DeclaredWebhookReader;
/** Self-heal subscription on the activation ledger — bound only with {@link declared}. */
Expand Down Expand Up @@ -499,6 +548,16 @@ export class AutoEnqueuer {
for (const row of rows) {
const sub = this.parseRow(row);
if (!sub) continue;
// A row parked for its retired method (see `parseRow`) is never
// sent, so neither credential is resolved for it: a parked row
// carries no secret and no header map (the #8069 park rule), and a
// decrypt for a subscription that cannot deliver buys nothing.
if (sub.parkedReason) {
this.reportRetiredMethod(sub);
add(sub);
continue;
}
this.retiredMethodReported.delete(sub.id);
// [#7799, #7986] Neither credential is in the row we just read —
// the signing key and the custom header map both live encrypted in
// `sys_secret`, and this read path returns only a mask. Dereference
Expand All @@ -521,7 +580,11 @@ export class AutoEnqueuer {
// deactivated. Otherwise the set grows for the life of the process, and
// a webhook turned off while broken and later turned back on still
// broken would have its first report suppressed as a repeat.
if (this.droppedForSecret.size > 0 || this.organizationRefusalReported.size > 0) {
if (
this.droppedForSecret.size > 0
|| this.organizationRefusalReported.size > 0
|| this.retiredMethodReported.size > 0
) {
const live = new Set(rows.map((r) => String(r?.id)));
for (const sub of declared.subscriptions) live.add(sub.id);
for (const id of this.droppedForSecret) {
Expand All @@ -531,6 +594,9 @@ export class AutoEnqueuer {
for (const id of this.organizationRefusalReported) {
if (!live.has(id)) this.organizationRefusalReported.delete(id);
}
for (const id of this.retiredMethodReported) {
if (!live.has(id)) this.retiredMethodReported.delete(id);
}
}

this.logger?.debug?.('[webhook-auto-enqueuer] cache refreshed', {
Expand Down Expand Up @@ -629,6 +695,13 @@ export class AutoEnqueuer {
definition_json: JSON.stringify({ timeoutMs: wh.timeoutMs }),
});
if (!sub) return null;
// `WebhookSchema` refuses a retired method, so a declaration parsed by
// `DeclaredWebhookSource` cannot carry one; a reader that hands one in
// anyway is parked by `parseRow` like a row, with no credentials.
if (sub.parkedReason) {
this.reportRetiredMethod(sub);
return sub;
}
const { secret } = splitWebhookSecret(wh as Record<string, unknown>);
const { headers } = splitWebhookHeaders(wh as Record<string, unknown>);
if (secret) sub.secret = secret;
Expand Down Expand Up @@ -1047,6 +1120,34 @@ export class AutoEnqueuer {
}
}

/**
* Report a subscription parked for its retired method, once
* ({@link retiredMethodReported}). `error` by the AGENTS.md question: the
* webhook keeps reading `active: true` in Setup while no matching event
* is delivered. The consequence and the fix are the park reason itself,
* which each dead row carries too.
*/
private reportRetiredMethod(sub: CachedSubscription): void {
if (this.retiredMethodReported.has(sub.id)) return;
this.retiredMethodReported.add(sub.id);
const message =
`[webhook-auto-enqueuer] webhook '${sub.name}' is PARKED: ${sub.parkedReason} Until then every matching `
+ 'record change is recorded in sys_http_delivery as a dead row with 0 attempts carrying this reason, '
+ 'while the row keeps reading active:true in Setup.';
const meta = {
id: sub.id,
webhook: sub.name,
method: sub.method,
code: RETIRED_METHOD_PARK_CODE,
status: RETIRED_METHOD_PARK_STATUS,
};
if (typeof this.logger?.error === 'function') {
this.logger?.error(message, undefined, meta);
} else {
this.logger?.warn?.(message, meta);
}
}

private parseRow(row: any): CachedSubscription | null {
if (!row?.id || !row?.url) return null;
// `triggers` is now authored as a multi-select (stored as an array), but
Expand Down Expand Up @@ -1127,17 +1228,26 @@ export class AutoEnqueuer {
}
}

const name = (row.name as string) ?? row.id;
// Method is authored via a select whose option values are lowercased
// (post/put/…); upper-case here so delivery uses a canonical HTTP
// method regardless of whether the row was authored before or after
// the select change (legacy rows stored 'POST').
const method = String(row.method ?? defn.method ?? 'POST').toUpperCase();
// A method no webhook can deliver with (`GET`, stored before the select
// and the spec dropped it) PARKS the subscription: it stays cached, and
// each event it matches is written as a terminal `dead` row carrying
// this reason instead of being enqueued (#8069's path). The method
// itself is carried through unchanged — parking never rewrites it.
const parkedReason = retiredMethodParkReason(name, method);
return {
id: row.id as string,
name: (row.name as string) ?? row.id,
name,
objectName: row.object_name ? String(row.object_name) : undefined,
triggers,
url: String(row.url),
// Method is authored via a select whose option values are lowercased
// (get/post/…); upper-case here so delivery uses a canonical HTTP
// method regardless of whether the row was authored before or after
// the select change (legacy rows stored 'POST').
method: String(row.method ?? defn.method ?? 'POST').toUpperCase(),
method,
...(parkedReason ? { parkedReason } : {}),
// `headers` and `secret` are both filled by attachCredentials()
// from their encrypted columns, NOT read off the row — see #7799
// (secret) and #7986 (headers).
Expand Down
11 changes: 9 additions & 2 deletions packages/plugins/plugin-webhooks/src/sys-webhook.object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,21 @@ export const SysWebhook = ObjectSchema.create({
}),

method: Field.select(
['GET', 'POST', 'PUT', 'PATCH', 'DELETE'],
['POST', 'PUT', 'PATCH', 'DELETE'],
{
label: 'HTTP Method',
required: true,
// Select instead of free text. Option values are lowercased by the
// Field.select helper (get/post/…); the auto-enqueuer upper-cases the
// Field.select helper (post/put/…); the auto-enqueuer upper-cases the
// resolved method before delivery, so existing 'POST' rows and the
// lowercase option values both normalise correctly.
//
// No `GET` (ADR-0049 enforce-or-remove, the spec's `WebhookSchema`
// `method` in step): every delivery carries the event as its body, so
// a GET webhook never delivered, and the select refusing it is what
// refuses it at save. A row stored with `get` before the option left
// is PARKED by the auto-enqueuer with the reason on a dead delivery
// row (`retiredMethodParkReason`); its method is never rewritten.
defaultValue: 'post',
description: 'HTTP method used for the callback request',
group: 'Definition',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export const arObjects: NonNullable<TranslationData['objects']> = {
label: "أسلوب HTTP",
help: "أسلوب HTTP المستخدم في طلب الاستدعاء",
options: {
get: "GET",
post: "POST",
put: "PUT",
patch: "PATCH",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

export const arGeneratedSourceHashes: Readonly<Record<string, string>> = {
"objects.sys_webhook.fields.method.options.delete": "f59e059ed51f9bfc",
"objects.sys_webhook.fields.method.options.get": "470848255971c548",
"objects.sys_webhook.fields.method.options.patch": "7de3603749decb30",
"objects.sys_webhook.fields.method.options.post": "004b24eab36d26a4",
"objects.sys_webhook.fields.method.options.put": "04d929ecae7aa435",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export const deObjects: NonNullable<TranslationData['objects']> = {
label: "HTTP-Methode",
help: "HTTP-Methode für die Callback-Anfrage",
options: {
get: "GET",
post: "POST",
put: "PUT",
patch: "PATCH",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
export const deGeneratedSourceHashes: Readonly<Record<string, string>> = {
"objects.sys_webhook.fields.definition_json.label": "efa6ad859212b898",
"objects.sys_webhook.fields.method.options.delete": "f59e059ed51f9bfc",
"objects.sys_webhook.fields.method.options.get": "470848255971c548",
"objects.sys_webhook.fields.method.options.patch": "7de3603749decb30",
"objects.sys_webhook.fields.method.options.post": "004b24eab36d26a4",
"objects.sys_webhook.fields.method.options.put": "04d929ecae7aa435",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export const enObjects: NonNullable<TranslationData['objects']> = {
label: "HTTP Method",
help: "HTTP method used for the callback request",
options: {
get: "GET",
post: "POST",
put: "PUT",
patch: "PATCH",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export const esESObjects: NonNullable<TranslationData['objects']> = {
label: "Método HTTP",
help: "Método HTTP utilizado en la solicitud de callback.",
options: {
get: "GET",
post: "POST",
put: "PUT",
patch: "PATCH",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

export const esESGeneratedSourceHashes: Readonly<Record<string, string>> = {
"objects.sys_webhook.fields.method.options.delete": "f59e059ed51f9bfc",
"objects.sys_webhook.fields.method.options.get": "470848255971c548",
"objects.sys_webhook.fields.method.options.patch": "7de3603749decb30",
"objects.sys_webhook.fields.method.options.post": "004b24eab36d26a4",
"objects.sys_webhook.fields.method.options.put": "04d929ecae7aa435",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ export const frObjects: NonNullable<TranslationData['objects']> = {
label: "Méthode HTTP",
help: "Méthode HTTP utilisée pour la requête de rappel",
options: {
get: "GET",
post: "POST",
put: "PUT",
patch: "PATCH",
Expand Down
Loading
Loading