Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic in index/resolver #259

Closed
4tsirata opened this issue Feb 23, 2024 · 2 comments
Closed

panic in index/resolver #259

4tsirata opened this issue Feb 23, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@4tsirata
Copy link

I just stumbled upon a panic in index/resolver.go line 517 while using vacuum linting a schema like the following one.

openapi: 3.0.3
info:
  description: test
  title: test
  version: test
paths: {}
components:
  schemas:
    test:
      type: object
      properties:
        Reference:
          $ref: '#/components/schemas/ReferenceType'
    ReferenceType:
      type: object
      required: [$ref]
      properties: 
        $ref:
          type: string
515			if i%2 == 0 && n.Value == "$ref" {
516
517				if !utils.IsNodeStringValue(node.Content[i+1]) {
518					continue
519				}

Maybe a check of the slice length could prevent the panic

515			if i%2 == 0 && n.Value == "$ref" && len(node.Content) > i%2+1 {
@daveshanley
Copy link
Member

Nice find! will fix.

@daveshanley daveshanley added the bug Something isn't working label Feb 27, 2024
daveshanley added a commit that referenced this issue Apr 18, 2024
@daveshanley daveshanley mentioned this issue Apr 18, 2024
daveshanley added a commit that referenced this issue Apr 19, 2024
@daveshanley
Copy link
Member

Your suggestion was added in v0.16.0

https://github.com/pb33f/libopenapi/blob/main/index/resolver.go#L514

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants