Skip to content

Green the validation gate and diagnose the Market feed 500 - #4

Draft
jongan69 wants to merge 2 commits into
mainfrom
claude/project-packaging-completion-vg8il5
Draft

Green the validation gate and diagnose the Market feed 500#4
jongan69 wants to merge 2 commits into
mainfrom
claude/project-packaging-completion-vg8il5

Conversation

@jongan69

Copy link
Copy Markdown
Owner

Packaging pass over the repository as it stood on August 10, 2026. Two independent changes.

1. Dependency drift broke npm run check

Seventeen packages had fallen behind the versions required by the installed Expo SDK, so the Expo Doctor stage of npm run check failed. Every gate downstream of it was effectively unrunnable as a single command.

All seventeen are patch-level moves inside SDK 57, plus react-native 0.86.0 to 0.86.2. Bumped to their expected ranges and refreshed the lockfile.

The lockfile was regenerated with npm 12 to match the version that produced it. The npm 10 present in the build environment silently strips libc metadata from optional-dependency entries, which would have been an unrelated 96-line deletion in the diff.

2. The Market feed 500 is a migration gap, not a code bug

GET /api/public/market/listings has been returning 500 since at least July 21 and still was on August 10. CURRENT_STATE.md listed the cause as unconfirmed.

worker/migrations/0002_marketplace_beta.sql was never applied to the remote D1 database. Every market table is absent in production, so each route that reads one fails.

Evidence against the deployed Worker:

Request Result
GET /api/public/market/listings 500
GET /api/public/market/listings?q=test 500
GET /api/public/market/listings/<any-slug> 500
GET /api/public/market/listings?radiusMiles=notanumber 400
GET /health 200

The 400 is the decisive one. A malformed query is rejected by validation before any database read, so routing, the handler and the error mapper are all working. Only requests that reach a market table fail, and they fail whichever table they touch.

Reproduced locally by applying every migration except the marketplace one to a scratch database: the feed returns the exact production error body with HTTP 500. Applying the held-back migration to that same database returns the feed to 200 and the detail route to a correct 404.

Why it stayed invisible

/health reported d1Configured: true the whole time, because that field only tested whether the D1 binding exists. It never queried the database, so a schema gap could not surface.

This PR adds a marketSchemaReady probe that counts the eight market tables in sqlite_master and returns false when any is missing. In the reproduction it reports d1Configured: true alongside marketSchemaReady: false, which is the state production is in right now.

What this PR does not do

It does not fix the outage. That needs Cloudflare credentials:

npx wrangler d1 migrations list seller-ai-db --remote   # expect 0002_marketplace_beta.sql pending
npm run db:migrate:remote

Verification steps are in docs/CURRENT_STATE.md. The migration is 13 CREATE ... IF NOT EXISTS statements, so re-application is safe.

Duplicate migration prefix

0002_device_push_tokens.sql and 0002_marketplace_beta.sql share a prefix. Tested, and it is not the cause: Wrangler tracks applied migrations by filename and still lists a late-added duplicate-prefix migration as pending. Left as-is deliberately, since renaming either file would make Wrangler treat it as new and re-run it.

Verification

npm run check passes at 20/20 Doctor checks, 34 safety invariants and 52 documentation files. npm run worker:check, npm run export:android and npm run web:export all succeed.

Not run here: native Android release build, device testing, and anything requiring Cloudflare or store credentials.


Generated by Claude Code

claude added 2 commits August 10, 2026 18:17
Seventeen packages had drifted behind the versions required by the
installed Expo SDK, failing `npm run check` at the Expo Doctor gate.

Bump all seventeen to their SDK-57 expected ranges (patch-level, plus
react-native 0.86.0 to 0.86.2) and refresh the lockfile.

Verified: `npm run check` passes 20/20 Doctor checks, 34 safety
invariants and 52 documentation files; `npm run worker:check`,
`npm run export:android` and `npm run web:export` all succeed.
The deployed public market feed has been returning HTTP 500 since at
least July 21. The cause is that 0002_marketplace_beta.sql was never
applied to the remote D1 database, so every market table is absent in
production and each route reading one fails.

The health endpoint could not reveal this. Its d1Configured field only
tested whether the DB binding exists, so it reported a healthy database
while an entire feature was down.

Add a marketSchemaReady probe that counts the eight market tables in
sqlite_master and returns false when any is missing, and record the
diagnosis, evidence and operator remediation in CURRENT_STATE.md.

Reproduced by applying every migration except the marketplace one to a
scratch database: health reports d1Configured true with
marketSchemaReady false while the feed returns the exact production
error body. Applying the held-back migration restores the feed to 200
and the detail route to 404.
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 50ee3e6d-c926-4667-a1d8-2b9987ecc033

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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.

2 participants