fix(catalog-etl): emit warn-severity EtlWarning for unresolvable secondary FK columns in terminals-sync#290
Open
GitAddRemote wants to merge 1 commit into
Open
fix(catalog-etl): emit warn-severity EtlWarning for unresolvable secondary FK columns in terminals-sync#290GitAddRemote wants to merge 1 commit into
GitAddRemote wants to merge 1 commit into
Conversation
…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
Contributor
There was a problem hiding this comment.
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-severityEtlWarningwhen 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', | ||
| ); | ||
| }); |
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.
Summary
TerminalsSyncSteppreviously silently storednullforstarSystemId,planetId,orbitId,moonId,factionId,companyIdwhen 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 savedseverity: 'warn'EtlWarningand storenull; if the source field is already null, no warning is emittedAlso closes #224: the terminal-distances spec mock was already correctly scoped to
FROM station_terminal(excludingstation_terminal_distance) — no additional change needed.Test plan
warnmessages are saved forstar_system,faction, andcompanymisses when source record has non-null UEX IDsterminals-sync.step.spec.tstests passterminal-distances-sync.step.spec.tstests passCloses #223
Closes #224