Skip to content

Add protocol mapper switch sanity test and correct existing switch errors - #1286

Merged
extremeheat merged 2 commits into
masterfrom
copilot/add-sanity-check-to-prevent-undefined-map-value
Sep 11, 2026
Merged

Add protocol mapper switch sanity test and correct existing switch errors#1286
extremeheat merged 2 commits into
masterfrom
copilot/add-sanity-check-to-prevent-undefined-map-value

Conversation

Copilot AI commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Protocol switches could reference values absent from their preceding mapper, causing undefined dispatch behavior. Add CI validation to detect these mismatches across protocol JSON files.

  • Validation: Traverse protocol types, resolve mapper aliases, and verify switch cases against previously defined mapper values.
  • Diagnostics: Log switches whose comparison field cannot be resolved; fail on known mapper mismatches.
  • Data fixes: Correct existing PC and Bedrock mapper/switch inconsistencies and regenerate affected protocol JSON.
if (!mapper.has(value)) {
  issues.push(`${location}: ${compareTo} -> ${value}`)
}

Co-authored-by: extremeheat <13713600+extremeheat@users.noreply.github.com>
Copilot AI changed the title [WIP] Add sanity check to prevent switching on undefined map value Add protocol mapper switch sanity checks Sep 9, 2026
Copilot AI requested a review from extremeheat September 9, 2026 05:10
Comment thread tools/js/test/test.js
if (!mapper.has(value)) issues.push(`${location}: ${options.compareTo} -> ${value}`)
}
} else if (options.compareTo) {
console.log(`${versionString}: unable to find ${options.compareTo} for switch at ${location}`)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hmm. Thinking about it it would make sense to put this into protodef-validator itself. But for now this seems like good stopgap fixing present protocol def bugs

@extremeheat
extremeheat marked this pull request as ready for review September 9, 2026 05:20
@extremeheat extremeheat changed the title Add protocol mapper switch sanity checks Add protocol mapper switch sanity test and correct existing switch errors Sep 11, 2026
@extremeheat
extremeheat merged commit 57fa53e into master Sep 11, 2026
7 checks passed
@extremeheat
extremeheat deleted the copilot/add-sanity-check-to-prevent-undefined-map-value branch September 11, 2026 07:29
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.

Add sanity check of sorts to prevent switching on undefined map value

2 participants