Skip to content

fix: prevent panic on empty mapping in sequence (#808)#809

Merged
reuvenharrison merged 4 commits intomainfrom
fix/issue-808-empty-seq-panic
Mar 16, 2026
Merged

fix: prevent panic on empty mapping in sequence (#808)#809
reuvenharrison merged 4 commits intomainfrom
fix/issue-808-empty-seq-panic

Conversation

@reuvenharrison
Copy link
Collaborator

@reuvenharrison reuvenharrison commented Mar 16, 2026

Summary

  • Fixes panic: runtime error: index out of range [0] with length 0 [recovered, repanicked] #808: panic index out of range [0] with length 0 when loading a spec with a YAML sequence containing an empty mapping node (e.g. security: - {})
  • Root fix is a one-line guard in oasdiff/yaml3's addOriginInSeq: skip origin injection when n.Content is empty
  • Bumps oasdiff/yaml3 to v0.0.1 and oasdiff/yaml to v0.0.1 via oasdiff/kin-openapi v0.135.1 replace directive

Note: #806 (false positive diffs on identical files) was already fixed in #807.

Test plan

  • TestDiff_EmptySecurityRequirementNoPanic — loads a spec with security: - {} and verifies no panic
  • All existing tests pass

🤖 Generated with Claude Code

@codecov-commenter
Copy link

codecov-commenter commented Mar 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 89.28%. Comparing base (8e14055) to head (1010a01).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #809   +/-   ##
=======================================
  Coverage   89.28%   89.28%           
=======================================
  Files         240      240           
  Lines       12715    12715           
=======================================
  Hits        11352    11352           
  Misses        907      907           
  Partials      456      456           
Flag Coverage Δ
unittests 89.28% <ø> (ø)

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

☔ View full report in Codecov by Sentry.
📢 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.

@reuvenharrison reuvenharrison changed the title fix: prevent panic on empty mapping node in sequence (#808) fix: prevent false positive diffs (#806) and panic on empty mapping in sequence (#808) Mar 16, 2026
reuvenharrison and others added 2 commits March 16, 2026 18:32
Updates oasdiff/yaml3 (via kin-openapi) to fix a panic in addOriginInSeq
when a YAML sequence contains an empty mapping node (e.g. `- {}`).

Fixes #808

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@reuvenharrison reuvenharrison force-pushed the fix/issue-808-empty-seq-panic branch from 9fbe809 to 3bba300 Compare March 16, 2026 16:32
@reuvenharrison reuvenharrison changed the title fix: prevent false positive diffs (#806) and panic on empty mapping in sequence (#808) fix: prevent panic on empty mapping node in sequence (#808) Mar 16, 2026
@reuvenharrison reuvenharrison changed the title fix: prevent panic on empty mapping node in sequence (#808) fix: prevent panic on empty mapping in sequence (#808) Mar 16, 2026
@reuvenharrison reuvenharrison merged commit f7ccbd2 into main Mar 16, 2026
14 checks passed
@reuvenharrison reuvenharrison deleted the fix/issue-808-empty-seq-panic branch March 16, 2026 17:35
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.

panic: runtime error: index out of range [0] with length 0 [recovered, repanicked]

2 participants