Skip to content

fix(Label_QQ): guard groundspeed on the actual 45..48 field, not remaining.text - #512

Open
fuleinist wants to merge 1 commit into
airframesio:masterfrom
fuleinist:fix/label-qq-groundspeed-guard
Open

fix(Label_QQ): guard groundspeed on the actual 45..48 field, not remaining.text#512
fuleinist wants to merge 1 commit into
airframesio:masterfrom
fuleinist:fix/label-qq-groundspeed-guard

Conversation

@fuleinist

@fuleinist fuleinist commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Fixes #507.

Problem

Label_QQ.decode() guards the groundspeed field by testing decodeResult.remaining.text !== '---', but at that point remaining.text holds the previous unknown field (substring(42, 45)), not the groundspeed field (substring(45, 48)). When 45..48 is --- but 42..45 is not (e.g. ...028---0009), the guard passes and Number('---') stores a NaN groundspeed, rendering "NaN knots".

Fix

Read the groundspeed field into a local (gsField) and include it in the guard:

const gsField = message.text.substring(45, 48);
if (decodeResult.remaining.text !== '---' && gsField !== '---') {
  ResultFormatter.groundspeed(decodeResult, Number(gsField));
} else {
  ResultFormatter.unknown(decodeResult, gsField);
}

Note: I intentionally kept the existing remaining.text check rather than replacing it with a check on gsField alone. The variant 2 fixture (...10.1---0200009) asserts that when the 42..45 field is ---, the following 020 is recorded as unknown rather than decoded as a 20-knot groundspeed. Guarding on gsField alone would change that established behavior; this version preserves both existing fixtures while eliminating the NaN path.

Tests

  • Added a regression test for the 028--- split: no groundspeed in raw, no GSPD formatted item, field recorded as unknown.
  • All existing Label_QQ tests unchanged and passing.
  • Full suite: 100 suites, 469 passed, 9 skipped (pre-existing).

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of Label QQ messages with unavailable groundspeed data.
    • Messages now decode successfully while preserving position, route, and remaining fields.
    • Unavailable groundspeed values are omitted instead of being displayed incorrectly.
  • Tests

    • Added regression coverage for messages containing unavailable groundspeed fields.

Copilot AI lite review requested due to automatic review settings August 4, 2026 12:40
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5867381c-50d8-4064-82f9-c8b2b28bcc28

📥 Commits

Reviewing files that changed from the base of the PR and between c4b61b4 and 1184c10.

📒 Files selected for processing (2)
  • lib/plugins/Label_QQ.test.ts
  • lib/plugins/Label_QQ.ts

Walkthrough

Label QQ groundspeed decoding now checks the extracted groundspeed field. A regression test covers a populated preceding field followed by the '---' placeholder and verifies partial decoding without NaN.

Changes

Label QQ groundspeed decoding

Layer / File(s) Summary
Groundspeed guard and regression coverage
lib/plugins/Label_QQ.ts, lib/plugins/Label_QQ.test.ts
The decoder records '---' as unknown instead of converting it to NaN. The regression test verifies position and route parsing, preserved remaining text, undefined groundspeed, and omitted groundspeed formatting.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: makrsmark

Poem

A rabbit checked the fields in line,
Found dashed speed, not a number fine.
No NaN hops through the route,
Unknown marks now safely sprout.
Tests watch every gentle sign.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the groundspeed guard fix in Label_QQ and matches the primary change.
Linked Issues check ✅ Passed The change reads the actual 45..48 groundspeed field and adds regression coverage for the split-field case in issue #507.
Out of Scope Changes check ✅ Passed The changes are limited to the Label_QQ decoder and its regression test, both directly related to issue #507.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Ready to approve

The fix addresses the documented NaN bug and adds a targeted regression test; remaining feedback is a minor test assertion/type-safety cleanup.

This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.

Pull request overview

Fixes Label_QQ.decode() groundspeed decoding so the --- placeholder is detected on the actual groundspeed field (45..48), preventing Number('---') from producing a NaN groundspeed and "NaN knots" output.

Changes:

  • Read groundspeed into a local gsField and guard decoding on gsField !== '---' (while preserving the existing remaining.text !== '---' behavior).
  • Add a regression test covering the 028--- split case to ensure groundspeed is not decoded and is recorded as unknown.
File summaries
File Description
lib/plugins/Label_QQ.ts Fix groundspeed placeholder guarding by checking the 45..48 groundspeed field directly.
lib/plugins/Label_QQ.test.ts Add regression coverage for the 028--- case (non-placeholder 42..45 followed by placeholder groundspeed).
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.

Comment on lines +134 to +135
expect(decodeResult.raw.groundspeed).toBeUndefined();
expect(Number.isNaN(decodeResult.raw.groundspeed)).toBe(false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Label_QQ groundspeed --- guard reads the wrong field (decodeResult.remaining.text), silently emits NaN groundspeed

2 participants