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.
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 multiple OpenAPI generation issues with new AST-based generator #18554
Fix multiple OpenAPI generation issues with new AST-based generator #18554
Changes from 3 commits
6a4bf8b
3b24b5a
de69c3d
7005f1a
85976b2
8d7fb45
759d69c
ad19b0d
8194c82
61afb41
78b6554
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
I was undecided as to whether I should add trace-level logging at this point.
On the plus side: It makes it easier for plugin developers to find out this condition is being hit.
On the minus side: It is additional logging which is uninteresting to server operators, as there is nothing that can be done to change it other than rebuilding the Vault or plugin binary, and it will trigger every time
sys/internal/specs/openapi
or any relevant HelpOperation is invoked.One alternative approach here would be to move the check to Backend.init, which is already set up to panic on initialisation if a backend author writes an empty or uncompilable path pattern - this could be expanded to include impossible-to-OpenAPI patterns not also marked as Unpublished. (I furthermore have another open PR, #18492, which seeks to add a check for CreateOperation being defined without an ExistenceCheck at the same point.)
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.
Perhaps a reasonable compromise could be added to change this error:
into a named error and then capturing it here with
if errors.Is(...) { return nil }
. The advantage of this approach is that the code will be explicit about the intention of skipping specific regex operations. IfcollectPathsFromRegexpASTInternal
is modified in the future to return other errors, those will be propagated correctly.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.
Done!
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.
Are all of these tests just not doing anything any more, or is there a need for more test cases to be added back in place of these?
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.
All of the tests being deleted, test the behaviour of various ad-hoc regexps, which were being used to parse other regexps (!).
They have all been deleted, and their job replaced by
regexp/syntax
from the Go standard library.The new code that has been written to process the output of the stdlib's
regexp/syntax
is already well-exercised by the existingTestOpenAPI_ExpandPattern
- although, I could add some additional inputs and expected outputs to that test, which would fail with the old implementation, but pass with this rewritten one.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.
These would be awesome! I would also love to see some of the edge cases tested like ".*" that you mentioned in the comments.
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.
Done!