Repository navigation
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The change causes false collision errors for ignored embedded fields and incorrect parent-value selection for dotted JSON tags.
2 open issues
What changed in this PR
Hardens go-zero configuration loading by rejecting ambiguous struct-field keys and making environment expansion explicit and consistent.
Changes:
- Reject case-colliding field keys while preserving map-key case.
- Share environment expansion rules across
LoadandLoadProperties. - Add regression tests and document the updated behavior.
| File | Description |
|---|---|
| core/conf/readme.md | Documents key matching and environment expansion. |
| core/conf/properties.go | Uses shared expansion with contextual errors. |
| core/conf/properties_test.go | Tests unset, empty, and escaped environment values. |
| core/conf/options.go | Implements shared environment expansion rules. |
| core/conf/config.go | Detects ambiguous keys and preserves nested map keys. |
| core/conf/config_test.go | Tests key collisions and environment handling. |
Review effort: Balanced
Comment on lines
+332
to
+333
| if lower := toLowerCase(k); info.children[lower] != nil { | ||
| if previous, ok := seen[lower]; ok { |
| res[k] = toLowerCaseKeyMap(vv, info) | ||
| } else { | ||
| res[k] = v | ||
| if child != nil { |
kevwan
force-pushed
the
fix/conf-ambiguous-keys-and-env-5852
branch
from
December 6, 2026 04:16
5d02d9d to
f3933e1
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.

Part of #5852 (item 3).
Summary
LoadandLoadProperties. WithUseEnv(), an unset variable returns an error, an explicitly empty variable expands to an empty string, and$$expands to one literal dollar.env=NAMEtag for field-level environment overrides.Validation
go test -race ./core/conf ./core/mapping ./internal/encoding.