Skip to content

Enhancement: Add default case handling in generated pbjs output#2095

Merged
dcodeIO merged 2 commits intoprotobufjs:masterfrom
saurabh-pingale:enhancement/add-eslint-disable-default-case
May 2, 2026
Merged

Enhancement: Add default case handling in generated pbjs output#2095
dcodeIO merged 2 commits intoprotobufjs:masterfrom
saurabh-pingale:enhancement/add-eslint-disable-default-case

Conversation

@saurabh-pingale
Copy link
Copy Markdown
Contributor

This PR introduces enhancements to the protobuf-generated files by adding a default case handling mechanism in the generated pbjs code.

Enhancement: #1106

Changes Introduced

  • Added default case in the generated header section to handle unexpected enum values.
  • Ensures safer parsing and avoids runtime issues when new/unknown values are encountered.

Screenshots & References

  1. Proto file used for testing (test.proto)
Screenshot 2025-08-18 202730
  1. Command used to generate pbjs file
pbjs -t static-module -w commonjs -o test.js test.proto
  1. Generated file showing default case in header
Screenshot 2025-08-18 202723

@dcodeIO dcodeIO merged commit 8723f3f into protobufjs:master May 2, 2026
3 of 4 checks passed
@github-actions github-actions Bot mentioned this pull request May 2, 2026
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