Skip to content

feat: make schema hash and version constants opt-in via -schemaHash#11

Merged
klaidliadon merged 1 commit into
masterfrom
feat/optional-version-funcs
Jun 19, 2026
Merged

feat: make schema hash and version constants opt-in via -schemaHash#11
klaidliadon merged 1 commit into
masterfrom
feat/optional-version-funcs

Conversation

@klaidliadon

@klaidliadon klaidliadon commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Generated files embed a schema hash in the header comment and in the WebRPCSchemaHash constant. The hash changes on every schema edit, so generated files conflict on essentially every rebase. This makes that metadata opt-in: a new -schemaHash target option (default off) drops the hash from the header and omits the version constants; passing -schemaHash restores 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

  • Default (no flag): header comment is // <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).

-help lists the new flag automatically.

Test plan

Regenerated _examples with the new default, and round-tripped the flag:

$ make -C _examples generate
$ git diff _examples
-// hello-webrpc v1.0.0 949b00a8db9810c69295f9dd9f02587a65d3c497
+// hello-webrpc v1.0.0
 // Code generated by webrpc-gen@… DO NOT EDIT.
   (WebRPCVersion / WebRPCSchemaVersion / WebRPCSchemaHash consts removed)

$ webrpc-gen … -schemaHash        # flag on → hash + all three consts restored
// hello-webrpc v1.0.0 949b00a8db9810c69295f9dd9f02587a65d3c497

@VojtechVitek VojtechVitek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

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.
@klaidliadon klaidliadon force-pushed the feat/optional-version-funcs branch from 1652622 to acb590f Compare June 19, 2026 12:15
@klaidliadon klaidliadon changed the title feat: make version constants and schema hash opt-in via -versionFuncs feat: make schema hash and version constants opt-in via -schemaHash Jun 19, 2026
@klaidliadon klaidliadon merged commit d94d403 into master Jun 19, 2026
1 check passed
@klaidliadon klaidliadon deleted the feat/optional-version-funcs branch June 19, 2026 13:07
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