chore: remove metaId fallback from AwsQldbLedger after backfill#117
chore: remove metaId fallback from AwsQldbLedger after backfill#117
Conversation
Agent-Logs-Url: https://github.com/MaximumTrainer/OpenFactstore/sessions/24ff4ee6-acea-4fd8-bbb6-63d010b996d9 Co-authored-by: MaximumTrainer <1376575+MaximumTrainer@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR removes the backward-compatibility metaId fallback in the QLDB ledger adapter after a production backfill ensured all documents now carry an explicit entryId.
Changes:
- Remove
metaIdprojection from the QLDBhistory(FactLedger)query. - Simplify
resolveEntryId()to only readentryId(or return empty string). - Update/trim tests to drop
metaIdfallback expectations while keeping type-mismatch coverage.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| backend/src/main/kotlin/com/factstore/adapter/outbound/AwsQldbLedger.kt | Removes metaId projection and drops metaId fallback in resolveEntryId() used by history reads. |
| backend/src/test/kotlin/com/factstore/adapter/outbound/AwsQldbLedgerEntryResolutionTest.kt | Updates tests to align with removal of metaId fallback and keeps coverage for missing/wrong-typed entryId. |
| // fallback branch (the `?: struct.get("metaId")` path inside it) and the metaId | ||
| // projection from the SELECT above. The resolveEntryId behaviour is covered by | ||
| // AwsQldbLedgerEntryResolutionTest. | ||
| val resolvedEntryId = resolveEntryId(struct) |
There was a problem hiding this comment.
getHistory() now relies solely on the explicit entryId. If production data is not fully backfilled (or a future write omits entryId), this will silently create LedgerEntry objects with entryId == "", which can break clients and makes diagnosing the bad document difficult. Consider failing fast (e.g., throw/log and skip the revision) when resolveEntryId(struct) returns blank, so incomplete backfills are detected immediately rather than producing invalid entries.
| val resolvedEntryId = resolveEntryId(struct) | |
| val resolvedEntryId = resolveEntryId(struct) | |
| if (resolvedEntryId.isBlank()) { | |
| log.error( | |
| "QLDB history revision for record {} is missing required entryId: {}", | |
| recordId, | |
| struct | |
| ) | |
| throw IllegalStateException("QLDB history revision for record $recordId is missing required entryId") | |
| } |
All QLDB documents have been backfilled with an explicit
entryIdfield, so themetaIdfallback code path introduced for backward compatibility with pre-migration documents can be removed.AwsQldbLedger.ktresolveEntryId()— drops themetaIdfallback branch; now readsentryIddirectly or returns""getHistory()query — removesh.metadata.id AS metaIdprojection; onlyh.metadata.txTime AS txTimeandh.data.*are selectedAwsQldbLedgerEntryResolutionTest.ktmetaIdfallback behaviour (falls back to metaId when entryId is missing,ignores non-IonText entryId field and falls back to metaId)resolveEntryIdtests to no longer referencemetaIdresolveEntryId returns empty string when entryId is not an IonTextto retain type-mismatch coverage without the fallback expectation