Skip to content

fix(parser): accept report modifiers before the delivery time - #833

Open
f-loris wants to merge 1 commit into
mivek:mainfrom
f-loris:fix/cor-modifier-before-time
Open

fix(parser): accept report modifiers before the delivery time#833
f-loris wants to merge 1 commit into
mivek:mainfrom
f-loris:fix/cor-modifier-before-time

Conversation

@f-loris

@f-loris f-loris commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Fixes parsing of a COR correction indicator placed before the delivery time group.

parseIdentification expected the station at a fixed offset after the optional METAR/SPECI prefix, and the delivery time immediately after the station. Any modifier in between was parsed as a station or as a time and threw a ParseException.

Two legal placements were affected:

MRLB COR 071700Z 11013KT 9999 FEW045 SCT100 34/22 A2983          # NOAA metars.cache.xml
METAR COR LFPG 081130Z 00000KT 0350 FG SCT000 M01/M01 Q1026      # ICAO Annex 3, App. 3

The library already models this: Flag.COR and isCorrected() exist, and parseFlags handles a COR that follows the delivery time. This change reuses parseFlags for the tokens preceding the delivery time, so all three placements behave the same and isCorrected() is set consistently. No new API.

Flag skipping is disabled at index 0, where only a report type or a station can appear -- otherwise AUTO, which is both a Flag and a four-letter token matching the station pattern, would be consumed as a modifier.

Tests

7 added to MetarParserTest covering the three COR placements, the uncorrected baseline, both truncated-message error paths, and the AUTO-at-index-0 guard.

mvn verify green: 661 tests, Checkstyle, SpotBugs and JaCoCo gates all passing.

A correction indicator is legal both between the report type and the station
("METAR COR LFPG 081130Z") and between the station and the delivery time
("MRLB COR 071700Z"), the latter being the form NOAA publishes. Both were
rejected because parseIdentification expected the station and the delivery
time at fixed offsets.

Reuse parseFlags for the tokens preceding the delivery time, so these reports
parse and isCorrected() reports them as corrected, consistent with a COR that
follows the delivery time and is already handled by the body of the message.
Flag skipping stays disabled at index 0, where only a report type or a station
can appear and where AUTO would otherwise shadow a four-letter station.
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown

Please check on sonarcloud https://sonarcloud.io/project/pull_requests_list?id=io.github.mivek%3AmetarParser that the PR does not add any issue.

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.

1 participant