feat: make schema hash and version constants opt-in via -schemaHash#11
Merged
Conversation
VojtechVitek
approved these changes
Jun 19, 2026
The schema hash in the file header comment and the WebRPCSchemaHash constant change on every schema edit, producing perpetual git merge conflicts in generated files. The version constants (WebRPCVersion, WebRPCSchemaVersion, WebRPCSchemaHash) are rarely consumed. Gate them behind a new -schemaHash target option (default false), flipping the previous always-on behavior: - default: header comment carries only the name and version (no hash), and no version constants are emitted. The "Code generated by ... DO NOT EDIT." line stays. - with -schemaHash: restores today's output exactly (hash in the header plus all three constants). Regenerated _examples to reflect the new default.
1652622 to
acb590f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Generated files embed a schema hash in the header comment and in the
WebRPCSchemaHashconstant. The hash changes on every schema edit, so generated files conflict on essentially every rebase. This makes that metadata opt-in: a new-schemaHashtarget option (default off) drops the hash from the header and omits the version constants; passing-schemaHashrestores today's output exactly.Part of a coordinated change across all webrpc generators (gen-golang, gen-typescript, gen-javascript, gen-dart, gen-kotlin, gen-openapi). Each is self-contained and safe to merge on its own. The default flip is intentionally a breaking change for anyone consuming these symbols, gated back on via
-schemaHash— worth a webrpc release-note callout.Behavior
// <name> <version>(no hash); no version constants emitted. The// Code generated by … DO NOT EDIT.line is kept.-schemaHash: restores today's output byte-for-byte (hash in header +WebRPCVersion/WebRPCSchemaVersion/WebRPCSchemaHash, export prefixes intact).-helplists the new flag automatically.Test plan
Regenerated
_exampleswith the new default, and round-tripped the flag: