You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Bug: Label_10_LDR, Label_10_POS, Label_1L_070, and Label_1L_3Line report position (0, 0) for empty lat/lon fields — silently places aircraft in the Gulf of Guinea #497
Every one of them has the same silent-(0, 0) failure as #487 (Label_2P_FM3) and #495 (Label_2P_FM4/FM5): when the field is empty ("") — or holds only a hemisphere letter with no magnitude (e.g. "N") — Number(...) returns 0, the ? 1 : -1 ternary defaults to -1, and the plugin emits position: { latitude: -0, longitude: -0 }. ResultFormatter.position only rejects NaN, so the (0, 0) result flows through unchecked and renders as "0.000 S, 0.000 W" — the middle of the Gulf of Guinea.
ResultFormatter.position also stores it into raw.position, so any downstream consumer that maps or track-plots the message drops a marker on the ocean instead of dropping the field entirely.
If parts[4] is "N" (hemisphere-only) getDirection('N') * Number("") === 1 * 0 === 0. If parts[4] is "", parts[4][0] is undefined and getDirection(undefined) returns NaN — that path is caught by ResultFormatter.position's isNaN guard, so only the "hemisphere with no magnitude" variant leaks through as (0, 0).
lib/plugins/Label_1L_3-line.ts:77-86
if(lat&&lon){// ← lat="N" is truthy → enters branchResultFormatter.position(decodeResult,{latitude:
CoordinateUtils.getDirection(lat[0])*Number(lat.substring(1)),longitude:
CoordinateUtils.getDirection(lon[0])*Number(lon.substring(1)),});data.delete('LAT');data.delete('LON');}
The if (lat && lon) guard rejects undefined / "" but happily accepts LAT N / LON W with no numeric magnitude — same 0 * 1 = 0 silent (0, 0).
Reproduction
Label_10_LDR with an empty lat field (16 well-formed fields plus an empty parts[5]):
Per-plugin fix — treat "no digits after the hemisphere" the same as "missing coordinate". A simple regex check works: reject if parts[X].substring(1).trim() is empty orNumber(...) returns NaN:
ResultFormatter.position hardening — extend the isNaN guard to also drop the (0, 0) case since it's never a valid ACARS position (the exact intersection of the equator and the prime meridian is not a real aircraft fix and shouldn't be reported as one):
For each of the four plugins, add regression tests where the lat/lon fields are "" and "N" / "W" (hemisphere-only), asserting no POS item is emitted and raw.position is not set.
Summary
Four label plugins parse the "N/S/E/W hemisphere + magnitude" coordinate form with the shape
Every one of them has the same silent-
(0, 0)failure as #487 (Label_2P_FM3) and #495 (Label_2P_FM4/FM5): when the field is empty ("") — or holds only a hemisphere letter with no magnitude (e.g."N") —Number(...)returns0, the? 1 : -1ternary defaults to-1, and the plugin emitsposition: { latitude: -0, longitude: -0 }.ResultFormatter.positiononly rejectsNaN, so the(0, 0)result flows through unchecked and renders as"0.000 S, 0.000 W"— the middle of the Gulf of Guinea.ResultFormatter.positionalso stores it intoraw.position, so any downstream consumer that maps or track-plots the message drops a marker on the ocean instead of dropping the field entirely.Affected code
lib/plugins/Label_10_LDR.ts:32-38parts.length < 17is guarded (line 22), soparts[5]andparts[6]exist, but they can still be"".lib/plugins/Label_10_POS.ts:24-32Same failure mode: empty
parts[1]orparts[2]→-0 / 100 = -0.lib/plugins/Label_1L_070.ts:55-62If
parts[4]is"N"(hemisphere-only)getDirection('N') * Number("") === 1 * 0 === 0. Ifparts[4]is"",parts[4][0]isundefinedandgetDirection(undefined)returnsNaN— that path is caught byResultFormatter.position'sisNaNguard, so only the "hemisphere with no magnitude" variant leaks through as(0, 0).lib/plugins/Label_1L_3-line.ts:77-86The
if (lat && lon)guard rejectsundefined/""but happily acceptsLAT N/LON Wwith no numeric magnitude — same0 * 1 = 0silent (0, 0).Reproduction
Label_10_LDR with an empty lat field (16 well-formed fields plus an empty
parts[5]):Label_10_POS with both lat and lon empty:
Label_1L_3Line with
LAT N\r\nLON Wand no magnitudes:Suggested fix
Two orthogonal changes:
Per-plugin fix — treat "no digits after the hemisphere" the same as "missing coordinate". A simple regex check works: reject if
parts[X].substring(1).trim()is empty orNumber(...)returnsNaN:ResultFormatter.positionhardening — extend theisNaNguard to also drop the(0, 0)case since it's never a valid ACARS position (the exact intersection of the equator and the prime meridian is not a real aircraft fix and shouldn't be reported as one):Change Some position decoding improvement #2 also closes the same failure surface for Bug: Label_2P_FM3 else-branch reports position (0, 0) for empty lat/lon fields — silently places aircraft in the Gulf of Guinea #487 and Bug: Label_2P_FM4 and Label_2P_FM5 report position (0, 0) for empty lat/lon fields — same silent Gulf-of-Guinea failure as Label_2P_FM3 (#487) #495 without needing per-plugin fixes.
Test coverage
For each of the four plugins, add regression tests where the lat/lon fields are
""and"N"/"W"(hemisphere-only), asserting noPOSitem is emitted andraw.positionis not set.