Skip to content

fix(keeper): validate store entries on load and extract round-id comparator - #198

Open
Olasunkanmi975 wants to merge 1 commit into
Sub-Rosa-Issue:mainfrom
Olasunkanmi975:fix/keeper-validate-store-entries-194
Open

fix(keeper): validate store entries on load and extract round-id comparator#198
Olasunkanmi975 wants to merge 1 commit into
Sub-Rosa-Issue:mainfrom
Olasunkanmi975:fix/keeper-validate-store-entries-194

Conversation

@Olasunkanmi975

Copy link
Copy Markdown

Summary

Resolves #194.

The keeper store previously trusted whatever was in .keeper-store.json. A single malformed or non-numeric round entry would:

  • break listRounds() ordering, which did BigInt() directly on the id, and
  • surface as a full corrupted-file backup that wiped every entry instead of just the bad one.

This change makes load robust and orders rounds consistently.

Changes

  • Drop malformed entries on load (services/keeper/src/store.ts): each round entry is validated with normalizeRoundId; a non-numeric/invalid id (or non-object value) is logged and skipped individually. The whole-file corrupted-JSON backup is preserved for truly unparseable files.
  • Extract compareRoundIds() numeric comparator: listRounds() and parseRoundIdSpec() (in keeper.ts) now share one comparator so rounds are ordered by numeric value regardless of id type (bigint / number / string).

Tests

  • Updated the store test that expected a full-file backup for a single bad entry; now asserts the bad entry is dropped while valid entries survive and no corrupted backup is created.
  • Added tests for non-numeric keys, and for compareRoundIds ordering across id types.

All 70 keeper tests and tsc typecheck pass.

Closes #194

…d comparator

Previously a single malformed/non-numeric round entry in
.keeper-store.json caused listRounds() ordering (which did BigInt() on
the id) to throw, which the load path surfaced as a full corrupted-file
backup that dropped every entry.

- Drop individual malformed round entries on load instead of nuking the
  whole store (still warn, still back up on truly corrupted JSON).
- Extract a shared compareRoundIds() numeric comparator so listRounds
  and callers (parseRoundIdSpec) order rounds consistently regardless of
  id type.

Closes Sub-Rosa-Issue#194
@Olasunkanmi975

Copy link
Copy Markdown
Author

@karagozemin please kindly review and merge

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.

keeper: validate store entries on load and extract round-id ordering

1 participant