Skip to content

Make PathItem.Build() a bit more robust to malformed input#606

Open
justinclift-prvidr wants to merge 2 commits into
pb33f:mainfrom
justinclift-prvidr:panic_fix
Open

Make PathItem.Build() a bit more robust to malformed input#606
justinclift-prvidr wants to merge 2 commits into
pb33f:mainfrom
justinclift-prvidr:panic_fix

Conversation

@justinclift-prvidr

@justinclift-prvidr justinclift-prvidr commented Jul 16, 2026

Copy link
Copy Markdown

Stumbled over a panic when running vacuum on a slightly invalid openapi.yml file, which had an empty parameters: 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. 😄

@codecov

codecov Bot commented Jul 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.75%. Comparing base (0837c9b) to head (793fa3e).

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     
Flag Coverage Δ
unittests 99.75% <100.00%> (-0.03%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@justinclift-prvidr

Copy link
Copy Markdown
Author

Hmmm, that looks like a false coverage failure?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant