test(data-access): add ElectroDB Service construction CI gate#1637
Merged
rainer-friederich merged 4 commits intoMay 28, 2026
Conversation
…ce construction succeeds The Preflight entity introduced in 3.72.0 declared `createdBy` and `error` as `type: 'map'` without a `properties` schema. ElectroDB rejects that at `new Service(...)` time with `InvalidAttributeDefinition`, which breaks any downstream consumer that constructs the full v1 Service from the entity registry (e.g. spacecat-api-service `fixes.test.js`). No consumer hit it because api-service was pinned at 3.71.1 — surfacing now in the LLMO-5190 Phase 1 PR that bumps to 3.73.0. Aligns both attributes to `type: 'any'` to match the neighbor `result` attribute on the same entity. The existing `validate` functions already enforce the precise shape, so dropping the `map`+`properties` declaration loses no schema-level enforcement. Adds a type-assertion regression guard in `test/unit/models/preflight/preflight.schema.test.js` so a future revert to `type: 'map'` without `properties` fails fast. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Catches the class of regression that shipped in 3.72.0 and was fixed in 3.73.1 (PR #1636 — Preflight `createdBy` / `error` declared as `type: 'map'` without a `properties` block). ElectroDB validates schema shape eagerly at `new Service(...)` time, but this package never instantiates a Service in its runtime (PostgREST path), so invalid attribute declarations slip through unit tests and only surface days later in downstream consumers that DO construct a v1 Service from the registry (e.g. `spacecat-api-service/test/controllers/fixes.test.js`). Adds `electrodb` as a devDependency and a unit test that builds `new electrodb.Service(EntityRegistry.getEntities())` against the live registry. Any new entity is automatically covered — no per-entity wiring required. The test was verified to fail on origin/main before the #1636 fix (`InvalidAttributeDefinition: Invalid "properties" definition for Map attribute`) and pass after, so it is not a tautological assertion. Pinned to `electrodb@3.5.0` to match the version transitively resolved by spacecat-api-service today — the version that actually exercises this code path in production downstream CI. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
This PR will trigger a patch release when merged. |
Contributor
|
Great prevention layer — this is exactly the kind of safety net that should have been here from the start. The self-maintaining approach via the full registry is the right call; no per-entity boilerplate and any future addition is automatically covered. Thanks for closing the loop on this so quickly. LGTM 🙏 |
GeezerPelletier
approved these changes
May 28, 2026
ekremney
approved these changes
May 28, 2026
Member
|
🎉 This PR is included in version @adobe/spacecat-shared-data-access-v3.73.2 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Why
This PR adds a small CI gate that would have caught the regression we just fixed in #1636 at PR time, not days later in a downstream consumer's CI run.
The original incident (3.72.0): #1622 introduced the Preflight entity with
createdByanderrordeclared astype: 'map'without apropertiesblock. ElectroDB validates schema shape eagerly atnew Service(...)time and throwsInvalidAttributeDefinitionon that combination. Every existing unit test in this package passed because the v3 PostgREST runtime never instantiates an ElectroDB Service — so invalid attribute declarations are entirely invisible to this repo's CI.The bug surfaced two days later in spacecat-api-service#2506 (the LLMO-5190 Phase 1 PR that bumped to 3.73.0) because
test/controllers/fixes.test.jsconstructs the full v1 Service fromEntityRegistry.getEntities()for indexing-side-effect reasons. By then, 3.72.0 was already published.Fix shipped in #1636 → 3.73.1. This PR is the prevention.
What
electrodb@3.5.0as a devDependency ofspacecat-shared-data-access(no runtime dep added — the test-only import).test/unit/models/base/electrodb-service-construction.test.jswith two assertions:new electrodb.Service(EntityRegistry.getEntities())does not throw.Why this version of electrodb
Pinned to
electrodb@3.5.0— the version transitively resolved byspacecat-api-servicetoday. That's the version that actually exercises the failing code path in downstream CI, so this is the version we want to defend against. Bumping locally won't help if api-service stays on the older version.Why no per-entity wiring
The test reads the full registry at runtime. Any entity added to
entity.registry.jsis automatically covered — no boilerplate per new entity. The cost is one ~720ms test.Verified the test actually catches the bug
Ran it against
origin/main(pre-#1636) — failed exactly as predicted:So this is not a tautological "the schema is what the schema is" check — it genuinely exercises the validation path that broke.
Out of scope (intentional)
propertiesblocks). That's the kind of cleanup that creates more drift than it removes — thevalidatefunctions already enforce shape, and adding redundantpropertiesdeclarations would be dual-source-of-truth without buying anything.Dependency on #1636
This branch cherry-picks the #1636 fix commit so CI passes immediately. The two PRs are functionally independent — whichever lands first, the other rebases cleanly.
🤖 Generated with Claude Code