Reject unrecognized struct tags in FromStruct#11
Merged
phinze merged 1 commit intoApr 8, 2026
Conversation
mflags silently ignored struct tags it didn't understand, which meant typos and copy-paste mistakes from go-flags (like positional-args:"yes") would compile and run fine but never actually wire anything up. A sweep of the runtime CLI also turned up env and required tags that look intentional but have no effect today. FromStruct now validates every tag key on exported fields against the set of tags it actually reads, and returns an error listing all the unrecognized ones so you can fix them in one pass.
evanphx
approved these changes
Apr 8, 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.
mflags has always silently ignored struct tags it doesn't recognize. That's how
positional-args:"yes"(a go-flags tag) snuck through in MIR-984 without anyone noticing, and a sweep of the runtime CLI turned upenvandrequiredtags being used on dozens of fields with no effect.FromStruct()now validates every tag key on exported fields against the set of tags it actually reads. If anything doesn't match, it returns an error listing all the unrecognized tags at once so you can fix them in one pass. The allowlist is intentionally strict (only tags mflags implements today), so upgrading mflags in the runtime repo will surface both the go-flags holdovers and the aspirationalenv/requiredtags, prompting us to either add those features or clean up the structs.Closes MIR-985