Skip to content

fix(catalog-etl): emit warn-severity EtlWarning for unresolvable secondary FK columns in terminals-sync#290

Open
GitAddRemote wants to merge 1 commit into
mainfrom
feature/ISSUE-223
Open

fix(catalog-etl): emit warn-severity EtlWarning for unresolvable secondary FK columns in terminals-sync#290
GitAddRemote wants to merge 1 commit into
mainfrom
feature/ISSUE-223

Conversation

@GitAddRemote
Copy link
Copy Markdown
Owner

Summary

  • TerminalsSyncStep previously silently stored null for starSystemId, planetId, orbitId, moonId, factionId, companyId when the source UEX ID couldn't be resolved to a local row — the inline comment said "warn and null out" but no warning was ever saved
  • Each secondary FK column now follows the same pattern as the primary location FKs: if the source field is non-null but the lookup misses, save a severity: 'warn' EtlWarning and store null; if the source field is already null, no warning is emitted
  • Row is still upserted regardless — consistent with primary-location FK miss behaviour

Also closes #224: the terminal-distances spec mock was already correctly scoped to FROM station_terminal (excluding station_terminal_distance) — no additional change needed.

Test plan

  • New test: asserts warn messages are saved for star_system, faction, and company misses when source record has non-null UEX IDs
  • All 28 terminals-sync.step.spec.ts tests pass
  • All 8 terminal-distances-sync.step.spec.ts tests pass
  • ESLint and Prettier clean

Closes #223
Closes #224

…ndary FK columns in terminals-sync

- Replace silent null-fallback for starSystemId, planetId, orbitId, moonId, factionId, companyId with explicit warning saves when the source record has a non-null UEX ID that can't be resolved in the local lookup map
- Row is still upserted with the FK stored as null — consistent with primary location FK behaviour
- Add test: asserts warn messages are saved for star_system, faction, and company misses; no warning when UEX source field is null

Closes #223
Closes #224
Copilot AI review requested due to automatic review settings June 2, 2026 20:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the catalog ETL TerminalsSyncStep to emit persisted warn-severity EtlWarning records when secondary FK UEX IDs are present but cannot be resolved to local rows, while still upserting terminals with null FKs (matching the existing “primary location FK miss” behavior).

Changes:

  • Emit warn-severity EtlWarning when secondary FK lookups miss (star system, planet, orbit, moon, faction, company) and the source UEX ID is non-null.
  • Add a new spec asserting warnings are emitted for unresolvable secondary FKs.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.

File Description
backend/src/modules/catalog-etl/steps/terminals-sync.step.ts Adds warning emission for unresolved secondary FK columns during terminal upsert preparation.
backend/src/modules/catalog-etl/steps/terminals-sync.step.spec.ts Adds a test validating warn-severity warnings are produced for unresolved secondary FK references.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +253 to +258
this.warningsRepo.create({
runId: ctx.runId,
stepName: this.name,
severity: 'warn',
message: `Terminal ${record.id} references unknown star system ${record.id_star_system} — FK stored as null`,
}),
Comment on lines +268 to +273
this.warningsRepo.create({
runId: ctx.runId,
stepName: this.name,
severity: 'warn',
message: `Terminal ${record.id} references unknown planet ${record.id_planet} — FK stored as null`,
}),
Comment on lines +283 to +288
this.warningsRepo.create({
runId: ctx.runId,
stepName: this.name,
severity: 'warn',
message: `Terminal ${record.id} references unknown orbit ${record.id_orbit} — FK stored as null`,
}),
Comment on lines +298 to +303
this.warningsRepo.create({
runId: ctx.runId,
stepName: this.name,
severity: 'warn',
message: `Terminal ${record.id} references unknown moon ${record.id_moon} — FK stored as null`,
}),
Comment on lines +313 to +318
this.warningsRepo.create({
runId: ctx.runId,
stepName: this.name,
severity: 'warn',
message: `Terminal ${record.id} references unknown faction ${record.id_faction} — FK stored as null`,
}),
Comment on lines +328 to +333
this.warningsRepo.create({
runId: ctx.runId,
stepName: this.name,
severity: 'warn',
message: `Terminal ${record.id} references unknown company ${record.id_company} — FK stored as null`,
}),
Comment on lines +247 to +252
// Resolve secondary FK columns — warn when source has a UEX ID that can't be resolved
let starSystemId: number | null = null;
if (record.id_star_system !== null) {
starSystemId = starSystemByUexId.get(record.id_star_system) ?? null;
if (starSystemId === null) {
await this.warningsRepo.save(
Comment on lines +414 to +417
expect(warnMessages).toContain(
'Terminal 1 references unknown company 88 — FK stored as null',
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants