fix(localizer): remove redundant PBFieldOpts concat in protogen error template#423
Merged
Conversation
… template
The protogen error template appended PBFieldOpts after TypeCell as
"{{.TypeCell}}|{{.PBFieldOpts}}", but every protogen write site of
KeyTypeCell already stores the full type-cell string (including its
`|{prop}` segment):
- protogen/util.go (wrapDebugErr) writes header.getTypeCell(cursor),
which is the raw type-row line untouched by prop stripping.
- importer/book/node.go (Node.DebugKV) writes n.Value, the raw scalar
from the YAML/JSON document, also including the full prop.
Meanwhile KeyPBFieldOpts is written from prop.Text / desc.Prop.Text,
which is a substring of the same type cell. The template therefore
duplicated the prop section on every protogen error, e.g.:
TypeCell: int64|{"refer:ItemConf.ID"}|"refer:ItemConf.ID"
confgen and default templates do not reference PBFieldOpts at all, so
no path actually needs the concatenation.
Drop the `|{{.PBFieldOpts}}` suffix from both zh.yaml and en.yaml.
KeyPBFieldOpts is kept since it still shows up as its own line in the
debug field block (fieldsString) and is useful for locating prop
parsing failures (prop.Text has braces stripped, so it is not strictly
equal to TypeCell).
|
The latest Buf updates on your PR. Results from workflow Buf CI / buf (pull_request).
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #423 +/- ##
=======================================
Coverage 74.95% 74.95%
=======================================
Files 88 88
Lines 9408 9408
=======================================
Hits 7052 7052
Misses 1784 1784
Partials 572 572 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
wenchy
approved these changes
Jun 30, 2026
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.
Problem
When protogen reports a field error, the rendered message duplicates the prop segment:
The protogen template renders
TypeCellas:Root cause
Audited every write site of
xerrors.KeyTypeCellandxerrors.KeyPBFieldOpts:protogen/util.gowrapDebugErr→header.getTypeCellint64|{...}importer/book/node.goNode.DebugKV→n.Valueint64|{...}KeyPBFieldOptsprop.Text/desc.Prop.Text/field.optsSo in the protogen path,
TypeCellalways already carries the prop, andPBFieldOptsis just the same substring appended again.confgenanddefaulttemplates do not referencePBFieldOptsat all, so removing the concat has no impact there.Fix
Drop the
|{{.PBFieldOpts}}suffix fromTypeCellin bothzh.yamlanden.yaml.Why
xerrors.KeyPBFieldOptsis keptxerrors/desc.go fieldsString), useful for locating prop parsing failures — note thatprop.Texthas its outer{}stripped, so it isn't strictly identical toTypeCell.After
Verification
go test ./internal/localizer/... ./internal/x/xerrors/...✅go test ./internal/protogen/... ./internal/confgen/...✅Scope
Localized error template only; no production code changes.