fix: prevent panic on invalid paths entries during index build#197
Merged
TristanSpeakEasy merged 2 commits intomainfrom Apr 8, 2026
Merged
fix: prevent panic on invalid paths entries during index build#197TristanSpeakEasy merged 2 commits intomainfrom
TristanSpeakEasy merged 2 commits intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a panic during OpenAPI index building when paths contains invalid (non-object) entries, ensuring validation errors are surfaced instead of crashing.
Changes:
- Added a helper to detect typed-nil interface values and applied guards in
getCoreModelFromAny/getRootNodeFromAny. - Added a regression test covering malformed
pathsentries and asserting no panic + expected validation error output.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| openapi/sanitize.go | Adds typed-nil detection/guards to prevent nil dereferences during indexing and sanitization. |
| openapi/index_test.go | Adds regression test to ensure invalid paths entries don’t panic and produce validation errors. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
📊 Test Coverage ReportCurrent Coverage: Coverage Change: ✅ No change Coverage by Package
📋 Detailed Coverage by Function (click to expand)
Generated by GitHub Actions |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
2ynn
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.
Summary
Fixes a panic during index building when
pathscontains invalid entries.Linear ticket: GEN-2864
What changed
openapi/sanitize.gofor:getCoreModelFromAnygetRootNodeFromAnyopenapi/index_test.go:TestBuildIndex_InvalidPathsEntries_NoPanicAndValidationErrors_Successpathsentries:/api/v1/foo: []foo: barWhy
Previously, invalid path-item structures could produce typed-nil interface values that were dereferenced during index walking, causing a nil pointer panic before users saw actionable validation errors.
Validation
mise test -run TestBuildIndex_InvalidPathsEntries_NoPanicAndValidationErrors_Success ./openapimise test -run TestBuildIndex_ ./openapimise ci