Skip to content

exporters/vspec: warn on unmapped units instead of silent drop - #193

Open
SoundMatt wants to merge 1 commit into
COVESA:mainfrom
SoundMatt:fix/vspec-warn-on-unmapped-unit
Open

exporters/vspec: warn on unmapped units instead of silent drop#193
SoundMatt wants to merge 1 commit into
COVESA:mainfrom
SoundMatt:fix/vspec-warn-on-unmapped-unit

Conversation

@SoundMatt

Copy link
Copy Markdown

Small fix to a quiet data-loss path in the vspec exporter.

If a user writes unit: SomeUnit = SOME_VALUE in their GraphQL schema and SOME_VALUE isn't present in UNITS_DICT (the hardcoded SCREAMING_SNAKE_CASE → abbreviated VSS name map at the top of vspec.py), the unit was previously dropped from the YAML output with no warning — the user's intent silently vanished, and they'd have to diff the output to notice.

This PR adds a log.warning when an unmapped unit is encountered, naming both the field and the unit value, so the user can either:

  • add the unit to UNITS_DICT, or
  • adjust their schema to use a unit that's already mapped.

No behaviour change for fields with mapped units.

The existing TODO at this site about using vss-tools dynamic_units directly is intentionally left in place — that's a bigger refactor and deserves its own PR.

Tests

Adds tests/test_vspec.py covering:

  • a schema with one mapped unit (M"m") and one unmapped unit (BANANA) → asserts the mapped one round-trips, the unmapped one is dropped, and the warning fires with both the field path and unit value
  • a schema with only mapped units → asserts no UNITS_DICT warnings fire

Local verification: 534 passed (the deselected tests need the graphql-inspector Node CLI; CI has it).

Previously, if a user wrote 'unit: SomeUnit = SOME_VALUE' in their
schema and SOME_VALUE was not present in UNITS_DICT, the unit was
dropped from the YAML output with no warning. The user intent
silently vanished.

Add a log.warning when an unmapped unit is encountered, naming the
field and the unit value so the user can either add it to UNITS_DICT
or adjust their schema. No behaviour change for mapped units. The
existing TODO at this site is intentionally left in place because
the broader 'use vss-tools dynamic_units directly' refactor is
still outstanding.

Adds tests/test_vspec.py covering both the warn-and-drop path and
the no-warn path for mapped units.

Signed-off-by: Matt Jones <47545907+SoundMatt@users.noreply.github.com>
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