antify / antify/database

sortFixturesByDependency silently fails due to CLI filename-based fixture naming mismatch

Open
#10 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
0
Forks
0
Avg merge
11m
Merged PRs (30d)
1

Description

Describe the bug
When running fixtures via CLI (db load-fixtures), the fixture loader assigns fixture names based on their filenames (e.g., smsMessage.fixture). If a dependent fixture lists short names in dependsOn() (e.g., ['smsMessage']), the strict equality check in sortFixturesByDependency fails to find the dependency and silently falls back to alphabetical execution order without throwing an unhandled dependency error.

Steps to Reproduce

Create a data source fixture smsMessage.fixture.ts.

Create a dependent read model fixture conversation.fixture.ts with dependsOn: () => ['smsMessage'] (or dependsOn: () => ['smsMessage.fixture'] when using defineFixture name overrides).

Run db load-fixtures via CLI.

Observe the execution log order.

Expected Behavior

The CLI loader should either respect explicit name properties inside defineFixture({ name: 'smsMessage' }) or strip the .fixture extension when resolving dependency graph keys.

If a dependency listed in dependsOn() cannot be matched against any registered fixture name, sortFixturesByDependency should throw an explicit error (e.g., Dependency "smsMessage" not found for fixture "conversation"), rather than silently skipping the node and falling back to alphabetical execution order.

Actual Behavior

The CLI loader registers the fixture as smsMessage.fixture.

depends-handler.ts executes fixtures.find((_fixture) => _fixture.name === dependency).

Evaluation 'smsMessage.fixture' === 'smsMessage' returns false, resulting in undefined.

The dependency resolution silently fails, pushing conversation.fixture to run prematurely (alphabetically on 'C' before 'S' and 'T').

Downstream read models query empty collection tables and insert 0 documents.

Environment

Core Package: @antify/database

CLI Command: db load-fixtures

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the db load-fixtures command and inspect depends-handler.ts, especially sortFixturesByDependency and its fixture-name comparison. Reproduce the mismatch with smsMessage.fixture and conversation.fixture; done means dependencies resolve using the intended names or an unmatched dependency produces an explicit error instead of alphabetical execution.

Written by the indexing model from the issue text.

Assessment

Tech stack
mongodb, typescript
Domain
cli, database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
70/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.