Skip to content

Read the error reason out of data, not just message - #15

Merged
garethx merged 2 commits into
mainfrom
fix/delivery-groups-error-rendering
Aug 26, 2026
Merged

Read the error reason out of data, not just message#15
garethx merged 2 commits into
mainfrom
fix/delivery-groups-error-rendering

Conversation

@leggetter

Copy link
Copy Markdown
Contributor

Closes #11.

What changed

describeHookdeckPayload handled message and errors but not data. Hookdeck's 422s put the human reason in data, so the whole body fell through to the stringify fallback:

Before

Hookdeck API request failed (HTTP 422): PUT /connections — {"level":"info","handled":true,
"report":true,"data":["Delivery groups are not enabled for this organization"],
"status":422,"code":"UNPROCESSABLE_ENTITY"}

After

Hookdeck API request failed (HTTP 422): PUT /connections — Delivery groups are not enabled for this organization

Both captured by running the node's own transport against the live API, not just the unit mock.

The defect was never that the reason was missing. It was that it arrived behind "level":"info" and handled:true, which makes a hard failure look like debug output from a broken node.

Also: Delivery Group Key now says in its description that delivery groups are early access and what publishing does without them. The failure otherwise lands at publish time, after you have configured the option.

Testing

npm run lint 0 errors, 2 warnings (the accepted icon ones)
npm run build pass
npm run scan pass
verify-package-load.mjs 29 checks
node --test test/unit.test.mjs 109/109

Two new tests. The first uses the captured body verbatim and asserts "level" and handled do not reach the message — a test that only checked the reason was present would have passed before this change too, since the reason was always in the stringified blob. The second pins the case where both message and data are set, which the existing suite had but never exercised (its fixture carried a message, so the data array was dead weight).

I did not run test:live; nothing here touches provisioning or delivery.

Notes

No version bump, per CONTRIBUTING.md — the tag is the version. On its own this is a 0.2.1.

Worth knowing while #11 is open elsewhere: the underlying API behaviour is unchanged. A reader who configures Delivery Groups without the entitlement still cannot use them; they now get told why in a sentence. The hookdeck/website announcement has an open question about whether delivery groups reach GA before that post ships.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XtT85W8PPr2S8RW2WhCtpi

leggetter and others added 2 commits August 25, 2026 18:22
Hookdeck does not always put the human reason in `message`. A delivery-group
upsert on a project without the entitlement answers:

  {"level":"info","handled":true,"report":true,
   "data":["Delivery groups are not enabled for this organization"],
   "status":422,"code":"UNPROCESSABLE_ENTITY"}

`describeHookdeckPayload` knew about `message` and `errors`, so this fell
through to the stringify fallback and the whole body reached the activation
banner. The user met `"level":"info"` and `handled:true` before the reason —
on a hard failure, which reads as a broken node rather than a feature the
organization has not been given.

Reading `data` turns it into:

  Hookdeck API request failed (HTTP 422): PUT /connections — Delivery groups
  are not enabled for this organization

Verified against the live API, not only the unit mock.

The two tests use the captured body verbatim and assert the internal fields do
not survive, because the defect was never that the reason was missing — it was
that the reason arrived behind four fields that made it look like debug output.

Delivery Group Key now also says in its description that this is an early
access feature and what happens on publish without it. The failure landing at
publish time, after the option is configured, is the part worth pre-empting.

Closes #11

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XtT85W8PPr2S8RW2WhCtpi
The unit tests cover this shape with a stub, which fixes the shape in place: if
Hookdeck changed where it puts the reason, they would keep passing while users
went back to reading `"level":"info"` on a hard failure.

A delivery-group upsert on a project without the entitlement is the one live
case that reaches this path, and the suite already meets it. Asserting the
envelope is absent before skipping costs nothing and ties the rendering to a
real response. Checked against the unfixed code, where it fails.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@garethx
garethx force-pushed the fix/delivery-groups-error-rendering branch from 1469020 to 9974159 Compare August 26, 2026 09:10
@garethx
garethx merged commit 9fd6887 into main Aug 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delivery Groups 422 renders as raw JSON leading with "level":"info"

2 participants