Skip to content

fix: terminals-sync step should warn on unresolved secondary FK columns #223

@GitAddRemote

Description

@GitAddRemote

User Story

As an operator monitoring ETL health, I want warnings emitted when secondary FK columns (star_system_id, planet_id, orbit_id, moon_id, faction_id, company_id) can't be resolved so I can identify data gaps rather than silently receiving null values.

Definition of Done

  • TerminalsSyncStep emits a warn-severity EtlWarning for each secondary FK column that resolves to null due to a missing UEX ID (not just when the field is null in the source data)
  • Tests cover the warning emission for at least one secondary FK miss

Acceptance Criteria

  • When a terminal record has a non-null id_star_system (or other secondary FK field) that cannot be resolved to a local BIGINT id, an EtlWarning is saved with severity: 'warn' and a message identifying the unresolved UEX ID
  • Terminals with unresolvable secondary FKs are still upserted (null stored), consistent with current behavior for primary location FKs

Technical Elaboration

Currently terminals-sync.step.ts silently nulls out starSystemId, planetId, orbitId, moonId, factionId, companyId when the UEX ID isn't found in the local lookup map. The inline comment says "warn and null out" but no warning is emitted.

The fix is to add warning calls similar to what's already done for the primary location FKs (space_station, outpost, city), before falling through to the upsert with null.

Design Elaboration

Keep the current behavior of still upserting the row with null FKs — this matches the pattern for primary location FK misses and avoids data loss for terminals with partial FK coverage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions