Repository navigation
fix(backend): repair schema snapshot tooling and regenerate health/ready snapshots (#1378) - #1493
Merged
Junirezz merged 3 commits intoOct 3, 2026
Conversation
|
@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! 🚀 |
…th-snapshot-indexer # Conflicts: # backend/src/apiContractSnapshots.ts
…th-snapshot-indexer # Conflicts: # backend/src/__tests__/issues711.test.ts # backend/src/apiContractSnapshots.ts
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.
fix(backend): repair schema snapshot tooling and regenerate health/ready snapshots
Problem
schema-snapshots/get-_health.jsonandget-_ready.jsonfell out of sync with theindexercheck that/healthand/readyreturn. The snapshots were never regenerated when the check was added because the snapshot tooling onmaindoesn't run:src/apiContractSnapshots.tsis missing a closing}indiffSchemaShapes(inside thecurrentRequiredloop). The module doesn't parse, sonpm run snapshots:write,npm run snapshots:checkand the whole Backend: Add API contract schema snapshots for backward-compatibility checks #711 test suite crash withUnexpected "export".indexerentries onmainwere typed in by hand. They have no trailing newline, and the generator always writes one, so the files aren't generator output.writeAllSnapshots()inbeforeAll. That overwrote the committed files before the "compatible with committed snapshots" test, so a stale committed snapshot could never fail CI.indexer" test removedindexerfrom the live shape instead of the baseline. It was testing field removal, not snapshot drift.npm run snapshots:writenpm run snapshots:check✅ ... backward-compatiblejest issues711.test.tsbeforeAllrewrites it firstchecks.indexernew field added/now requiredSolution
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.tsfor (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)) {key in X.properties ?? {}parses as(key in X.properties) ?? {}. It now uses thebaselineProps/currentPropsvalues already defined above in the same function.backend/schema-snapshots/get-_health.json,get-_ready.jsonRegenerated 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.tsbeforeAll(writeAllSnapshots)so tests check the committed files instead of rewriting them.indexer.JsonSchemaShape, which existing tests already used as a type.Regression Tests
committed snapshots match generator output byte-for-bytehealth and ready snapshots include the indexer checkchecks.indexer(enum, required) in/healthanddependencies.indexer(boolean, required) in/readydetects newly added required fields as breaking changes(fixed)indexeris reported as driftpasses backward-compatibility check against committed snapshotsTesting
Negative check: with
main's hand-editedget-_health.jsonrestored, the new test fails as expected:On
main, before this fix:tsc --noEmitreports no errors in the changed files. ESLint shows onlyno-non-null-assertionwarnings, on lines that were already in the drift test.Notes for Reviewers
/healthand/readyhandlers and the Zod schemas are unchanged.git revert, with no persistent state./healthand/readyhandlers insrc/index.tswere checked against the schemas:checks.indexercomes fromgetEventPollingHealth().statusanddependencies.indexerfromstatus === 'up'. Both match the regenerated snapshots.main(ae82ae85):main's copy ofdiffSchemaShapeshad a duplicated, unclosedifline (a parse error again), andissues711.test.tsdeclaredcurrent/baselinetwice. The resolution keeps a single clean version, includingmain'scontinueand its comment on why the snapshot is the side missingindexer.dependencies.redistoget-_ready.jsonbut not toReadyResponseSchema, so regenerating would have dropped it.redisis now in the Zod schema, and the generated snapshot matchesmain's byte for byte. Note that/readyinsrc/index.tsdoes not yet returnredis, so that runtime gap from fix: check Redis connectivity in /ready health probe #1513 remains."nullable": truetonextCursoronly. The generator never writesnullable(the other nullable pagination fields don't have it either) and the compatibility check ignores it, so the file keeps the generator output.maincurrently hassrc/middleware/apiKeyAuth.tscommitted as base64 text, which stops backend suites from loading through the global Jest setup. That is outside this PR. The Backend: Add API contract schema snapshots for backward-compatibility checks #711 suite passes 14/14 when run without that setup file.Closes #1378