api: HEAD requests fail for derived JSON endpoints
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- typescript
Research direction
Start in packages/function/src/worker.ts: the catalogResponse function (around lines 209-224) and the schema route (around lines 67-73). Both call .json() on an asset or API response that is empty for HEAD requests. Reproduce with curl -I 'https://models.dev/model-schema.json' and the multi-type api.json?type=... query. Done means HEAD returns the same status and headers as GET without parsing a body, and the existing 15 worker tests still pass, plus new HEAD regression tests for the schema and multi-type routes.
Written by the indexing model from the issue text.
Description
HEAD returns 500 for /model-schema.json and multi-type catalog requests, while the corresponding GET requests return 200. Plain /api.json works with both methods.
Reproduced locally and on the public site; still present on current dev, 8b715df235126f6efcf4ab9b2e41c45f5ec74184.
Reproduction
curl -I 'https://models.dev/api.json' # 200, control
curl -I 'https://models.dev/api.json?type=chat,decision' # 500
curl -I 'https://models.dev/model-schema.json' # 500
curl -sS -o /dev/null -w '%{http_code}\n' \
'https://models.dev/model-schema.json' # GET: 200
Cause
In catalogResponse, the asset request inherits HEAD. The asset correctly has no response body, but the multi-type path calls assetResponse.json(). The schema route similarly calls apiResponse.json(). Both throw SyntaxError: Unexpected end of JSON input.
Local regression tests reproduce this on all four multi-type catalog routes and on schema requests. GET/static-HEAD controls, invalid-type 400 and conditional HEAD/304 pass. A separate real loopback HTTP asset server reproduces the schema failure too. The failures repeated across ten runs; the existing 15 worker tests pass. Environment: macOS 15.6.1/arm64, Bun 1.4.4.
Expected: return the appropriate metadata without parsing a bodyless asset response or sending HEAD response content. See RFC 9110, 9.3.2.
I'd like to work on a fix limited to HEAD handling and regression tests, keeping GET output, type validation, ETags/304s and CORS unchanged. Would that scope fit?
- Dominant language
- TypeScript
- Stars
- 7.5k
- Forks
- 2k
- Avg merge
- 39m
- Merged PRs (30d)
- 904
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from anomalyco/models.dev
-
automation missing-model model-sync provider:fireworks-ai
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
anomalyco/models.dev#12458 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
anomalyco/models.dev#11866 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 80/100
anomalyco/models.dev#11768 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
anomalyco/models.dev#11493 ·
Maintainers usually reply within 1 day
-
Amazon as Lab ?Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
anomalyco/models.dev#8163 · 1 comment ·
Maintainers usually reply within 1 day
All issues in anomalyco/models.dev
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 85/100
formbricks/formbricks#9918 ·
Maintainers usually reply within 1 day
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
thecodacus/pithagoras#364 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 72/100
openclimatefix/quartz-frontend#823 ·
Maintainers usually reply within 4 days
-
area:agent-manager community needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
`contacts.create` posts to `/audiences/undefined/contacts` when `audienceId` is undefinedPossibly taken @RaphaelFakhri claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
resend/resend-node#1176 ·
Maintainers usually reply within 1 day