Green the validation gate and diagnose the Market feed 500 - #4
Draft
jongan69 wants to merge 2 commits into
Draft
Conversation
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.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Packaging pass over the repository as it stood on August 10, 2026. Two independent changes.
1. Dependency drift broke
npm run checkSeventeen packages had fallen behind the versions required by the installed Expo SDK, so the Expo Doctor stage of
npm run checkfailed. Every gate downstream of it was effectively unrunnable as a single command.All seventeen are patch-level moves inside SDK 57, plus
react-native0.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
libcmetadata 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/listingshas been returning 500 since at least July 21 and still was on August 10.CURRENT_STATE.mdlisted the cause as unconfirmed.worker/migrations/0002_marketplace_beta.sqlwas 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:
GET /api/public/market/listingsGET /api/public/market/listings?q=testGET /api/public/market/listings/<any-slug>GET /api/public/market/listings?radiusMiles=notanumberGET /healthThe 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
/healthreportedd1Configured: truethe 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
marketSchemaReadyprobe that counts the eight market tables insqlite_masterand returnsfalsewhen any is missing. In the reproduction it reportsd1Configured: truealongsidemarketSchemaReady: 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:remoteVerification steps are in
docs/CURRENT_STATE.md. The migration is 13CREATE ... IF NOT EXISTSstatements, so re-application is safe.Duplicate migration prefix
0002_device_push_tokens.sqland0002_marketplace_beta.sqlshare 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 checkpasses at 20/20 Doctor checks, 34 safety invariants and 52 documentation files.npm run worker:check,npm run export:androidandnpm run web:exportall succeed.Not run here: native Android release build, device testing, and anything requiring Cloudflare or store credentials.
Generated by Claude Code