-
Notifications
You must be signed in to change notification settings - Fork 146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(AIP-203): avoid panic if name field is missing #1282
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @radhus this is a great catch. I think we need to adjust the solution. Can we instead just skip the rule if there the resource name field does not exist? Meaning, put this check into the OnlyIf
:
OnlyIf: func(m *desc.MessageDescriptor) bool {
return utils.IsResource(m) && m.FindFieldByName(utils.GetResourceNameField(utils.GetResource(m))) != nil
}
Could even put that name field existence check into a helper if you'd like.
The core functionality of this rule is not to enforce that the resource name field must exist - that is/should be a different rule. This rule must only lint the one thing it is meant to lint for. This makes the fine grained configuration more accurate.
7895fe6
to
2c1b523
Compare
@noahdietz you're right, this is even covered by AIP-123 already. Took your suggestion, much cleaner, and I like the pattern of keeping the rule of only linting one thing! |
@radhus thank you very much! |
This will be in v1.59.1 #1283 |
🤖 I have created a release *beep* *boop* --- ## [1.59.1](https://togithub.com/googleapis/api-linter/compare/v1.59.0...v1.59.1) (2023-11-01) ### Bug Fixes * **AIP-203:** skip identifier check if missing name field ([#1282](https://togithub.com/googleapis/api-linter/issues/1282)) ([2050717](https://togithub.com/googleapis/api-linter/commit/2050717c5f965a7374956f87b35ee048d1f2f53a)) --- This PR was generated with [Release Please](https://togithub.com/googleapis/release-please). See [documentation](https://togithub.com/googleapis/release-please#release-please).
Contains fix for AIP-203 panic: googleapis/api-linter#1282
Contains fix for AIP-203 panic: googleapis/api-linter#1282
This proto reproduces the following crash:
With the fix, the lint rule will skip checking when there is no
name
field - this is covered byAIP-123
.