Skip to content

fix(backend): repair schema snapshot tooling and regenerate health/ready snapshots (#1378) - #1493

Merged
Junirezz merged 3 commits into
Junirezz:mainfrom
solaawojobi00-bit:fix/issue-1378-health-snapshot-indexer
Oct 3, 2026
Merged

Junirezz merged 3 commits into
Junirezz:mainfrom
solaawojobi00-bit:fix/issue-1378-health-snapshot-indexer

Conversation

@solaawojobi00-bit

@solaawojobi00-bit solaawojobi00-bit commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

fix(backend): repair schema snapshot tooling and regenerate health/ready snapshots

Problem

schema-snapshots/get-_health.json and get-_ready.json fell out of sync with the indexer check that /health and /ready return. The snapshots were never regenerated when the check was added because the snapshot tooling on main doesn't run:

  • src/apiContractSnapshots.ts is missing a closing } in diffSchemaShapes (inside the currentRequired loop). The module doesn't parse, so npm run snapshots:write, npm run snapshots:check and the whole Backend: Add API contract schema snapshots for backward-compatibility checks #711 test suite crash with Unexpected "export".
  • The indexer entries on main were typed in by hand. They have no trailing newline, and the generator always writes one, so the files aren't generator output.
  • The Backend: Add API contract schema snapshots for backward-compatibility checks #711 suite ran writeAllSnapshots() in beforeAll. That overwrote the committed files before the "compatible with committed snapshots" test, so a stale committed snapshot could never fail CI.
  • The "snapshot missing indexer" test removed indexer from the live shape instead of the baseline. It was testing field removal, not snapshot drift.
Scenario Before After
npm run snapshots:write Crashes (TransformError) Writes all snapshots
npm run snapshots:check Crashes (TransformError) ✅ ... backward-compatible
jest issues711.test.ts Suite fails to load (0 tests) 14/14 pass
Committed snapshot is stale or hand-edited Hidden: beforeAll rewrites it first Test fails
Older snapshot lacks checks.indexer Test compared the wrong direction Reported as new field added / now required

Solution

Fix the parse error so the generator runs again, regenerate the snapshots with npm run snapshots:write, and stop the test suite from overwriting committed files. The suite now checks that the committed snapshots match the generator exactly.

Changes

backend/src/apiContractSnapshots.ts

     for (const key of baselineRequired) {
-      if (!(key in baseline.properties ?? {})) {
+      if (!(key in baselineProps)) {
 ...
     for (const key of currentRequired) {
-      if (!(key in current.properties ?? {})) {
+      if (!(key in currentProps)) {
         issues.push({ ... 'required field missing from live schema properties (invalid schema)' });
+      }
       if (!baselineRequired.has(key)) {
  • Adds the missing brace, so the "field is now required" check sits at the loop level rather than inside the orphaned-reference branch.
  • key in X.properties ?? {} parses as (key in X.properties) ?? {}. It now uses the baselineProps / currentProps values already defined above in the same function.

backend/schema-snapshots/get-_health.json, get-_ready.json

Regenerated with npm run snapshots:write. The content was already correct; the only diff is the trailing newline the generator writes, so the files now match the tooling's output exactly.

backend/src/__tests__/issues711.test.ts

Regression Tests

Test Covers
committed snapshots match generator output byte-for-byte Snapshots must be regenerated whenever the health check set changes; hand edits or stale files fail
health and ready snapshots include the indexer check checks.indexer (enum, required) in /health and dependencies.indexer (boolean, required) in /ready
detects newly added required fields as breaking changes (fixed) A snapshot missing indexer is reported as drift
passes backward-compatibility check against committed snapshots Now runs against committed files, not freshly written ones

Testing

$ npm run snapshots:check
✅ API contract schema snapshots are backward-compatible.

$ npx jest src/__tests__/issues711.test.ts --coverage=false
    √ defines snapshots for all critical public endpoints
    √ passes backward-compatibility check against committed snapshots
    √ detects removed fields as breaking changes
    √ detects newly added required fields as breaking changes
    √ validates a conforming health payload
    √ rejects health payloads missing required fields
    √ validates a conforming vault summary payload
    √ validates a conforming transactions list payload
    √ writes snapshot files under schema-snapshots/
    √ generates stable snapshot shapes for each endpoint
    √ detects orphaned required references in baseline snapshot
    √ detects new fields added to live schema
    √ committed snapshots match generator output byte-for-byte
    √ health and ready snapshots include the indexer check
Tests:       14 passed, 14 total

Negative check: with main's hand-edited get-_health.json restored, the new test fails as expected:

    × committed snapshots match generator output byte-for-byte
Tests:       1 failed, 13 passed, 14 total

On main, before this fix:

$ npm run snapshots:check
Error: Transform failed with 1 error:
src/apiContractSnapshots.ts:292:0: ERROR: Unexpected "export"

tsc --noEmit reports no errors in the changed files. ESLint shows only no-non-null-assertion warnings, on lines that were already in the drift test.

Notes for Reviewers

Closes #1378

@drips-wave

drips-wave Bot commented Sep 29, 2026

Copy link
Copy Markdown

@solaawojobi00-bit Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

…th-snapshot-indexer

# Conflicts:
#	backend/src/apiContractSnapshots.ts
…th-snapshot-indexer

# Conflicts:
#	backend/src/__tests__/issues711.test.ts
#	backend/src/apiContractSnapshots.ts
@Junirezz
Junirezz merged commit b6e0024 into Junirezz:main Oct 3, 2026
14 of 27 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.

Health check schema snapshot omits indexer field after adding the check

2 participants