Skip to content

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

@gxosty

Description

@gxosty

Describe the bug
Out of sudden we started getting this error in our integration check. It panics out when comparing 2 identical API schemas.

To Reproduce
Steps to reproduce the behavior:

  1. oasdiff breaking schema.yml schema.yml --fail-on ERR
  2. The spec file. schema.yml (both old and new schema are the same)
  3. Output:
running oasdiff breaking... base: schema-main.yml, revision: schema-current.yml, fail_on: , include_checks: , include_path_params: false, deprecation_days_beta: , deprecation_days_stable: , exclude_elements: , filter_extension: , composed: false, output_to_file: 
flags: 
panic: runtime error: index out of range [0] with length 0 [recovered, repanicked]

goroutine 1 [running]:
github.com/oasdiff/yaml3.handleErr(0x21ab59a3f220)
	/go/pkg/mod/github.com/oasdiff/[email protected]/yaml.go:302 +0x65
panic({0xb599c0?, 0x21ab599b2b70?})
	/usr/local/go/src/runtime/panic.go:860 +0x[13](https://github.com/asman-tech/business-backend/actions/runs/23141303841/job/67218015854#step:14:14)a
github.com/oasdiff/yaml3.addOriginInSeq(...)
	/go/pkg/mod/github.com/oasdiff/[email protected]/origin.go:22
github.com/oasdiff/yaml3.(*decoder).sequence(0x21ab5961c900, 0x21ab59841680, {0xad4ca0?, 0x21ab59baf0b0?, 0x10?})
	/go/pkg/mod/github.com/oasdiff/[email protected]/decode.go:756 +0x491
github.com/oasdiff/yaml3.(*decoder).unmarshal(0x21ab5961c900, 0x21ab59841680, {0xad4ca0?, 0x21ab59baf0b0?, 0x21ab59baf030?})
	/go/pkg/mod/github.com/oasdiff/[email protected]/decode.go:5[14](https://github.com/asman-tech/business-backend/actions/runs/23141303841/job/67218015854#step:14:15) +0x2ed
github.com/oasdiff/yaml3.(*decoder).mapping(0x21ab5961c900, 0x21ab598408c0, {0xad4ca0?, 0x21ab59bae510?, 0x21ab59b67e80?})
	/go/pkg/mod/github.com/oasdiff/[email protected][15](https://github.com/asman-tech/business-backend/actions/runs/23141303841/job/67218015854#step:14:16)a242b/decode.go:857 +0xa9f
github.com/oasdiff/yaml3.(*decoder).unmarshal(0x21ab5961c900, 0x21ab598408c0, {0xad4ca0?, 0x21ab59bae510?, 0x21ab59ba4870?})
	/go/pkg/mod/github.com/oasdiff/[email protected]/decode.go:512 +0x36c
github.com/oasdiff/yaml3.(*decoder).mapping(0x21ab5961c900, 0x21ab59840780, {0xad4ca0?, 0x21ab59bae4d0?, 0x10?})
	/go/pkg/mod/github.com/oasdiff/[email protected]/decode.go:857 +0xa9f
github.com/oasdiff/yaml3.(*decoder).unmarshal(0x21ab5961c900, 0x21ab59840780, {0xad4ca0?, 0x21ab59bae4d0?, 0x21ab59b815d0?})
	/go/pkg/mod/github.com/oasdiff/[email protected]/decode.go:512 +0x36c
github.com/oasdiff/yaml3.(*decoder).mapping(0x21ab5961c900, 0x21ab59739cc0, {0xad4ca0?, 0x21ab5992deb0?, 0x10?})
	/go/pkg/mod/github.com/oasdiff/[email protected]/decode.go:857 +0xa9f
github.com/oasdiff/yaml3.(*decoder).unmarshal(0x21ab5961c900, 0x21ab59739cc0, {0xad4ca0?, 0x21ab5992deb0?, 0x21ab5992d790?})
	/go/pkg/mod/github.com/oasdiff/[email protected]/decode.go:512 +0x36c
github.com/oasdiff/yaml3.(*decoder).mapping(0x21ab5961c900, 0x21ab59739540, {0xad4ca0?, 0x21ab597d0d80?, 0x6fde0a?})
	/go/pkg/mod/github.com/oasdiff/[email protected]/decode.go:857 +0xa9f
github.com/oasdiff/yaml3.(*decoder).unmarshal(0x21ab5961c900, 0x21ab59739540, {0xad4ca0?, 0x21ab597d0d80?, 0x21ab59a3f1c8?})
	/go/pkg/mod/github.com/oasdiff/[email protected]/decode.go:512 +0x36c
github.com/oasdiff/yaml3.(*decoder).document(...)
	/go/pkg/mod/github.com/oasdiff/[email protected]/decode.go:529
github.com/oasdiff/yaml3.(*decoder).unmarshal(0x21ab5961c900, 0x21ab597394a0, {0xad4ca0?, 0x21ab597d0d80?, 0x21ab597bf228?})
	/go/pkg/mod/github.com/oasdiff/[email protected]/decode.go:500 +0x1f3
github.com/oasdiff/yaml3.(*Decoder).Decode(0x21ab597bf3b0, {0xa995c0, 0x21ab597d0d80})
	/go/pkg/mod/github.com/oasdiff/[email protected]/yaml.go:140 +0x1fc
github.com/oasdiff/yaml.yamlToJSON(0x21ab597bf3b0, 0x21ab59a3f2f0)
	/go/pkg/mod/github.com/oasdiff/[email protected]/yaml.go:131 +0x45
github.com/oasdiff/yaml.unmarshal(0xbb3d20?, {0xb8c060, 0x21ab595f4210}, {0x0, 0x0, 0x0})
	/go/pkg/mod/github.com/oasdiff/[email protected]/yaml.go:67 +0xa9
github.com/oasdiff/yaml.UnmarshalWithOrigin({0x21ab59800000, 0x3a4a1, 0x3a4a2}, {0xb8c060, 0x21ab595f4210}, {0xb0?, {0x7ffedb925c0f?, 0x21ab597bf448?}}, {0x0, 0x0, ...})
	/go/pkg/mod/github.com/oasdiff/[email protected]/yaml.go:62 +0x26f
github.com/getkin/kin-openapi/openapi3.unmarshal({0x21ab59800000, 0x3a4a1, 0x3a4a2}, {0xb8c060, 0x21ab595f4210}, 0x1, 0x21ab5961c7e0)
	/go/pkg/mod/github.com/getkin/[email protected]/openapi3/marsh.go:33 +0xde
github.com/getkin/kin-openapi/openapi3.(*Loader).loadFromDataWithPathInternal(0x21ab5972e580, {0x21ab59800000, 0x3a4a1, 0x3a4a2}, 0x21ab5961c7e0)
	/go/pkg/mod/github.com/getkin/[email protected]/openapi3/loader.go:176 +0x[16](https://github.com/asman-tech/business-backend/actions/runs/23141303841/job/67218015854#step:14:17)5
github.com/getkin/kin-openapi/openapi3.(*Loader).loadFromURIInternal(0x21ab5972e580, 0x21ab5961c7e0)
	/go/pkg/mod/github.com/getkin/[email protected]/openapi3/loader.go:84 +0x4b
github.com/getkin/kin-openapi/openapi3.(*Loader).LoadFromURI(0x21ab5972e580, 0x21ab5961c7e0)
	/go/pkg/mod/github.com/getkin/[email protected]/openapi3/loader.go:70 +0xc8
github.com/getkin/kin-openapi/openapi3.(*Loader).LoadFromFile(0x21ab5972e580, {0x7ffedb925c0f, 0xf})
	/go/pkg/mod/github.com/getkin/[email protected]/openapi3/loader.go:76 +0x95
github.com/oasdiff/oasdiff/load.from(0x21ab597d4101?, 0xba014c?)
	/go/src/app/load/load.go:25 +0x45
github.com/oasdiff/oasdiff/load.loadSpecInfo(0x989d6f?, 0x21ab597d4140)
	/go/src/app/load/spec_info.go:74 +0x1c
github.com/oasdiff/oasdiff/load.NewSpecInfo(0x21ab5972e580, 0xbad384?, {0x21ab59a3f680, 0x3, 0x11bac40?})
	/go/src/app/load/spec_info.go:44 +0x26
github.com/oasdiff/oasdiff/internal.normalDiff(0x21ab5972e580, 0x21ab59566a50)
	/go/src/app/internal/diff.go:104 +0xff
github.com/oasdiff/oasdiff/internal.calcDiff(0x21ab59566a50)
	/go/src/app/internal/diff.go:81 +0x8d
github.com/oasdiff/oasdiff/internal.getChangelog(0x21ab59566a50, {0xc31200, 0x21ab59558040}, 0x2)
	/go/src/app/internal/changelog.go:49 +0x45
github.com/oasdiff/oasdiff/internal.runBreakingChanges(0x7ffedb925c1f?, {0xc31200?, 0x21ab59558040?})
	/go/src/app/internal/breaking_changes.go:28 +0x25
github.com/oasdiff/oasdiff/internal.getBreakingChangesCmd.getRun.func2(0x21ab596fcf08, {0x21ab595c3be0, 0x2, 0xb9d8b7?})
	/go/src/app/internal/handlers.go:57 +0xec
github.com/spf13/cobra.(*Command).execute(0x21ab596fcf08, {0x21ab595c3ba0, 0x2, 0x2})
	/go/pkg/mod/github.com/spf13/[email protected]/command.go:1015 +0xb14
github.com/spf13/cobra.(*Command).ExecuteC(0x21ab596fc608)
	/go/pkg/mod/github.com/spf13/[email protected]/command.go:1148 +0x465
github.com/spf13/cobra.(*Command).Execute(...)
	/go/pkg/mod/github.com/spf13/[email protected]/command.go:1071
github.com/oasdiff/oasdiff/internal.run(0x21ab596fc608)
	/go/src/app/internal/run.go:65 +0x[18](https://github.com/asman-tech/business-backend/actions/runs/23141303841/job/67218015854#step:14:19)
github.com/oasdiff/oasdiff/internal.Run({0x21ab595780c0, 0x4, 0x4}, {0xc31200, 0x21ab59558040}, {0xc31200, 0x21ab59558048})
	/go/src/app/internal/run.go:33 +0x368
main.main()
	/go/src/app/main.go:10 +0x45

Expected behavior
To not panic and output successful result.

Desktop (please complete the following information):

  • OS: Ubuntu 24.04

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions