Make PathItem.Build() a bit more robust to malformed input#606
Open
justinclift-prvidr wants to merge 2 commits into
Open
Make PathItem.Build() a bit more robust to malformed input#606justinclift-prvidr wants to merge 2 commits into
justinclift-prvidr wants to merge 2 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #606 +/- ##
==========================================
- Coverage 99.78% 99.75% -0.03%
==========================================
Files 283 283
Lines 34456 34460 +4
==========================================
- Hits 34382 34376 -6
- Misses 46 55 +9
- Partials 28 29 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Author
|
Hmmm, that looks like a false coverage failure? |
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.
Stumbled over a panic when running vacuum on a slightly invalid
openapi.ymlfile, which had an emptyparameters:line under an operation, with no nodes underneath.Tracing that back, it turns out libopenapi does a two pass construction in
PathItem.Build()when creating the model and when it hits a problem it can leave nil references in the model.The consumer of this (doctor → vacuum in this case) may not handle a model with nil references well (ie panic).
This PR takes the fairly simple approach of making this code more robust so the construction continues to completion, returning an
errors.Join()of all the failing operations and avoiding leaving nil references. This should help consumers avoid these panics.Weirdly (?),
Paths.Build()seems to swallow errors so this problem can't be easily detected by consumers of the model. That seems to be a deliberate design choice (with a test for it!), so this PR just works with it. 😄