Repository navigation
Strip the generator version stamp from generated protos - #46
Merged
Merged
Conversation
protobuf-check fails on routine dependency PRs. ts-proto writes its own version and protoc's into a "// versions:" header block in every generated file, so bumping ts-proto rewrites those three comment lines, the CI drift check sees changes under src, and the PR goes red until someone regenerates and commits. Measured on the open renovate PR #45 (ts-proto 2.12.4 -> 2.13.0), that is the entire diff: three files, one comment line each, no generated code change at all. Drop the version block in scripts/protoc-gen.sh after generation, so the output depends only on the .proto input and the generator flags -- which is what the check is meant to police. The versions themselves stay recorded in package.json and in the workflow's protoc pin, and the "Code generated ... DO NOT EDIT" and "source:" header lines are untouched. Verified: with this change, regenerating under ts-proto 2.13.0 produces no diff, while adding a field to run_function.proto is still caught. Also add set -euo pipefail, so a protoc failure stops the run rather than leaving half-generated output for the post-processing step to rewrite. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Steven Borrelli <steve@borrelli.org>
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.
protobuf-checkfails on routine dependency PRs for a reason that has nothing to do with the protos.The problem
ts-proto writes its own version and protoc's into a
// versions:header block in every generated file. Bumping ts-proto rewrites those comment lines, the CI drift check sees changes undersrc, and the PR goes red until someone regenerates and commits.On the currently-open renovate PR #45 (ts-proto 2.12.4 → 2.13.0), that is the entire diff — three files, one comment line each, no generated code change at all:
This is why
maincarries commits like "regen protos" and "allow protoc to run" — the check has been demanding hand-regeneration for comment churn, which trains everyone to regenerate-and-commit on reflex. That is exactly the habit you do not want around a check whose job is to catch unintended changes to generated code.The fix
scripts/protoc-gen.shstrips the// versions:block after generation, so the output depends only on the.protoinput and the generator flags — which is what the check is meant to police.The
// Code generated by protoc-gen-ts_proto. DO NOT EDIT.and// source:lines are untouched, so the files are still clearly marked as generated. The versions themselves remain recorded inpackage.jsonand in the workflow's protoc pin, so provenance is not lost, just not duplicated into a file that is diffed byte-for-byte in CI.Verification
The check has to stop firing on noise without going blind. Both directions tested locally:
run_function.protorun_function.ts)npm run build,typecheck,lintand all 136 tests pass.Also
Added
set -euo pipefailto the script, so a protoc failure stops the run rather than leaving half-generated output for the new post-processing step to rewrite.Deliberately left alone: the
# Update this version when ts-proto in package.json is updatedcomment above the protoc pin inci.yaml. It is misleading — protoc's version is independent of ts-proto — but it is outside the scope of this fix.Once this lands, #45 can be rebased and should go green without a regen commit.
🤖 Generated with Claude Code