Skip to content

Add Label C1 Loadsheet decoder plugin#416

Open
thepacket wants to merge 1 commit intoairframesio:masterfrom
thepacket:plugin/label-c1
Open

Add Label C1 Loadsheet decoder plugin#416
thepacket wants to merge 1 commit intoairframesio:masterfrom
thepacket:plugin/label-c1

Conversation

@thepacket
Copy link
Copy Markdown

Adds a decoder for label C1 electronic loadsheet uplinks.

npm run build passes.

New plugin registered in official.ts and MessageDecoder.ts.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 22, 2026

Warning

Rate limit exceeded

@thepacket has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 55 minutes and 17 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 55 minutes and 17 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 29feb6f6-735e-4b8d-a009-e07a9ba618c5

📥 Commits

Reviewing files that changed from the base of the PR and between 10f9f69 and 2935425.

📒 Files selected for processing (3)
  • lib/MessageDecoder.ts
  • lib/plugins/Label_C1_Loadsheet.ts
  • lib/plugins/official.ts
✨ 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 and usage tips.

Copy link
Copy Markdown
Contributor

@kevinelliott kevinelliott left a comment

Choose a reason for hiding this comment

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

Summary

Adds Label_C1_Loadsheet for label C1 electronic loadsheet uplinks. Tolerant line-by-line parser with a single-line fallback that splits on known keywords. Registered last in MessageDecoder.ts/official.ts. No companion test file.

Verdict

Comment-only review — biggest single issue is the missing test coverage given how many fields this plugin tries to handle. The parsing logic is generally well-structured, but a few mismatches with the project's conventions and a couple of small bugs should be addressed.

Must Fix

  • Add a Label_C1_Loadsheet.test.ts. This plugin recognizes ~13 distinct field types — please cover them. At minimum: qualifiers(), the multi-line happy path from the doc-comment example, the single-line fallback (splitIntoFields keyword path), PRELIMINARY vs FINAL variants, the SI route-vs-free-text branch, the NOTOC: NO normalization, and a non-matching message.
  • Use ResultFormatter for shared concerns. Today the plugin sets raw.tail and pushes a custom code: 'TAIL' item with label 'Aircraft Registration', instead of calling ResultFormatter.tail(decodeResult, m[1]). Same for the route SI branch — ResultFormatter.departureAirport/arrivalAirport already exist and produce the canonical IATA/ICAO items. Direct raw.departure_iata = ... followed by a custom code: 'ROUTE' item bypasses the canonical "Origin/Destination" rows that consumers (and the test fixtures) expect.

Should Fix

  • Add a preambles qualifier if at all possible. Every C1 observation in your doc-comment begins with . (the FRAGDLH-style sender token). If that's reliable, preambles: ['.'] would prevent this plugin from running its full keyword scan against unrelated C1 traffic.
  • DDHHMM has no bounds validation. 190925 is fine, but 999999 is happily decoded as "Day 99 @ 99:99Z". Either validate dd <= 31, hh < 24, mm < 60, or document the looseness. Same applies to the loadsheet reference_time capture (free-form pass-through is fine; just be aware).
  • PAX regex captures wrong totals when classes are swapped. For input PAX C/Y 6/84 you bind classes = ['C','Y'] and counts = [6, 84] — perfect. For PAX Y/C 84/6 you'd produce {Y: 84, C: 6} which is correct, but the classLabel mapping has a duplicate entry: both C and J map to 'Business'. That's acceptable airline-data shorthand, but worth a comment explaining you're treating them as equivalent intentionally.
  • splitIntoFields is destructive across the input. It collapses \s{2,} to a single space before line-splitting. That's deliberate, but if a free-text SI line contains intentional double spaces, they're lost. Move the whitespace collapse inside per-line handling rather than at the top.
  • raw.day = Number(dd) clobbers the typed field. RawFields.day is number | string, so this is OK, but be aware the same raw.day slot is used by ResultFormatter.day() — if a future C1 message also arrives with a UTC timestamp elsewhere you may write twice. Consider raw.dtg_day to disambiguate.
  • const [_, dd, hh, mm] = m; — under stricter eslint configs the unused leading _ triggers @typescript-eslint/no-unused-vars. The codebase tends to use m[1]/m[2]/m[3] indexed access (see Label_15.ts). Optional cleanup.

Nits

  • The keyword-splitter list mixes 'AN ', 'PAX ', 'PAX/' etc. — some have trailing space, some have a slash. That's fine but awkward to maintain. Consider a [{name, regex}] table.
  • Doc-comment is excellent, very useful for future maintainers.
  • Saving decodeResult.raw.is_agm = true as a typed boolean is fine; just consistent with how other plugins represent markers (most use a formatted.items entry only, no raw field).
  • partial decode level when remaining.length === 0 but a section was unrecognized — small thing, but setDecodeLevel(decodeResult, anyMatched, remaining.length ? 'partial' : 'full') returns decoded: false if anyMatched was false. Confirm that's intended (it is, per the protocol).

Tests

None added. Please add Label_C1_Loadsheet.test.ts. See "Must Fix" above for coverage list.

Notes — Registration & Coexistence

  • Registered at the tail of pluginClasses and exported from official.ts. No other plugin claims label C1, so order is irrelevant.
  • No coexistence concerns.

Thanks @thepacket!

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.

2 participants