Skip to content

fix: HEAD /list 500 crash when caller has no read permission - #311

Merged
kptdobe merged 2 commits into
mainfrom
fix/head-list-500-x-error
Aug 6, 2026
Merged

fix: HEAD /list 500 crash when caller has no read permission#311
kptdobe merged 2 commits into
mainfrom
fix/head-list-500-x-error

Conversation

@kptdobe

@kptdobe kptdobe commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • ClickHouse logs showed 264 HEAD /list 500s over 7 days, none carrying an x-error header — root-caused to an uncaught TypeError.
  • getList/getVersionList return { status: 403 } (no body) when the caller has neither direct nor descendant read permission. head.js destructured body.length unconditionally, throwing before the request ever reached daResp(), so it skipped x-error entirely.
  • Fixed head.js to guard body access (body?.length ?? 0) for both /list and /versionlist.
  • Wrapped the method dispatch in index.js in try/catch so any future handler exception is converted to daResp({ status: 500, error }), guaranteeing x-error on all 5xx responses instead of a raw crash.

Test plan

  • test/handlers/head.test.js (new): reproduces the crash pre-fix, verifies 403 with contentLength: 0 post-fix for both /list and /versionlist, plus a success-path sanity check.
  • test/index.test.js: new case asserting x-error header is set when a handler throws unexpectedly.
  • npm test — 494 passing, no regressions.
  • npm run lint — clean.

getList/getVersionList return {status:403} with no body when caller
has no read permission. head.js destructured body.length unconditionally,
throwing a TypeError that escaped index.js uncaught, producing a raw 500
with no x-error header. Guard body access and catch handler errors in
index.js so 5xx responses always carry x-error.
@codecov

codecov Bot commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@kptdobe
kptdobe requested a review from buuhuu August 6, 2026 08:35
@kptdobe
kptdobe merged commit 5658b63 into main Aug 6, 2026
6 checks passed
@kptdobe
kptdobe deleted the fix/head-list-500-x-error branch August 6, 2026 09:02
adobe-bot pushed a commit that referenced this pull request Aug 6, 2026
## [1.14.1](v1.14.0...v1.14.1) (2026-08-06)

### Bug Fixes

* HEAD /list 500 crash when caller has no read permission ([#311](#311)) ([5658b63](5658b63))
@adobe-bot

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 1.14.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants