Code Monkey home page Code Monkey logo

doctor's Issues

Doctor Will Hang Indefinitely on Poorly Formatted Self References

As per our discord chat, opened this for tracking on your end since I saw that you prefer issues be on Github.

a root.yaml

paths:
  /v3/test:
    get:
      summary: test
      operationId: test
      responses:
        "200":
          description: Success
          content:
            application/json:
              schema:
                $ref: "schemas.yaml#/TestAccountV3"

referencing a schemas.yaml

TestAccountV3:
  type: object
  properties:
    parentAccount:
      $ref: "schemas.yaml#/TestAccountV3"
    liveAccount:
      $ref: "schemas.yaml#/TestAccountV3"
    provisionedForAccount:
      $ref: "schemas.yaml#/TestAccountV3"

Like so, will hang indefinitely. The reason that occurs is because of the following line:

https://github.com/pb33f/doctor/blob/main/model/high/base/schema_proxy.go#L61

	for _, ref := range circularRefs {
		if ref.LoopPoint.Definition == sp.Value.GetReference() {
			return true
		}
	}

Which never finds a match. The variable values are as follows:

ref.LoopPoint.Definition

is #/TestAccountV3, but

sp.Value.GetReference()

is schemas.yaml#/TestAccountV3.

This occurs because the schemas.yaml has a self reference that uses a file reference (adding in the schemas.yaml# to refer to a definition to itself).

As per your recommendation, this is most likely invalid or at least non standard but in that case should either error or be fixed to pass. My preference is for it to pass, but lint it in vacuum.

Doctor Will Trigger a Race Condition with Build Graph Enabled

Running doctor with build graph enabled triggers a race condition. Can be seen using vacuum with BuildGraph On.

WARNING: DATA RACE
Read at 0x00c00012c7c0 by goroutine 317:
  runtime.growslice()
      /nix/store/4cijk6gwv59c84h1l9yhxzsaz93f67mz-go-1.23.0/share/go/src/runtime/slice.go:177 +0x0
  github.com/pb33f/doctor/model/high/base.(*Foundation).AddEdge()
      <redacted>/vendor/github.com/pb33f/doctor/model/high/base/foundation.go:316 +0x94
  github.com/pb33f/doctor/model/high/v3.(*PathItem).AddEdge()
      <autogenerated>:1 +0x28
  github.com/pb33f/doctor/model/high/base.(*Foundation).BuildNodesAndEdges()
      <redacted>/vendor/github.com/pb33f/doctor/model/high/base/foundation.go:174 +0x800
  github.com/pb33f/doctor/model/high/v3.(*Operation).Walk()
      <redacted>/vendor/github.com/pb33f/doctor/model/high/v3/operation.go:33 +0x130
  github.com/pb33f/doctor/model/high/v3.(*PathItem).Walk.func1()
      <redacted>/vendor/github.com/pb33f/doctor/model/high/v3/path_item.go:81 +0x64
  github.com/sourcegraph/conc/panics.(*Catcher).Try()
      <redacted>/vendor/github.com/sourcegraph/conc/panics/panics.go:23 +0x70
  github.com/sourcegraph/conc.(*WaitGroup).Go.func1()
      <redacted>/vendor/github.com/sourcegraph/conc/waitgroup.go:32 +0x84

Previous write at 0x00c00012c7c0 by goroutine 318:
  github.com/pb33f/doctor/model/high/base.(*Foundation).AddEdge()
      <redacted>/vendor/github.com/pb33f/doctor/model/high/base/foundation.go:314 +0x154
  github.com/pb33f/doctor/model/high/v3.(*PathItem).AddEdge()
      <autogenerated>:1 +0x28
  github.com/pb33f/doctor/model/high/base.(*Foundation).BuildNodesAndEdges()
      <redacted>/vendor/github.com/pb33f/doctor/model/high/base/foundation.go:174 +0x800
  github.com/pb33f/doctor/model/high/v3.(*Server).Walk()
      <redacted>/vendor/github.com/pb33f/doctor/model/high/v3/server.go:26 +0x168
  github.com/pb33f/doctor/model/high/v3.(*PathItem).Walk.func9()
      <redacted>/vendor/github.com/pb33f/doctor/model/high/v3/path_item.go:138 +0x50
  github.com/sourcegraph/conc/panics.(*Catcher).Try()
      <redacted>/vendor/github.com/sourcegraph/conc/panics/panics.go:23 +0x70
  github.com/sourcegraph/conc.(*WaitGroup).Go.func1()
      <redacted>/vendor/github.com/sourcegraph/conc/waitgroup.go:32 +0x84

Goroutine 317 (running) created at:
  github.com/sourcegraph/conc.(*WaitGroup).Go()
      <redacted>/vendor/github.com/sourcegraph/conc/waitgroup.go:30 +0xd4
  github.com/pb33f/doctor/model/high/v3.(*PathItem).Walk()
      <redacted>/vendor/github.com/pb33f/doctor/model/high/v3/path_item.go:81 +0x234
  github.com/pb33f/doctor/model/high/v3.(*Paths).Walk.func1()
      <redacted>/vendor/github.com/pb33f/doctor/model/high/v3/paths.go:47 +0x50
  github.com/sourcegraph/conc/panics.(*Catcher).Try()
      <redacted>/vendor/github.com/sourcegraph/conc/panics/panics.go:23 +0x70
  github.com/sourcegraph/conc.(*WaitGroup).Go.func1()
      <redacted>/vendor/github.com/sourcegraph/conc/waitgroup.go:32 +0x84

Goroutine 318 (running) created at:
  github.com/sourcegraph/conc.(*WaitGroup).Go()
      <redacted>/vendor/github.com/sourcegraph/conc/waitgroup.go:30 +0xd4
  github.com/pb33f/doctor/model/high/v3.(*PathItem).Walk()
      <redacted>/vendor/github.com/pb33f/doctor/model/high/v3/path_item.go:138 +0xe2c
  github.com/pb33f/doctor/model/high/v3.(*Paths).Walk.func1()
      <redacted>/vendor/github.com/pb33f/doctor/model/high/v3/paths.go:47 +0x50
  github.com/sourcegraph/conc/panics.(*Catcher).Try()
      <redacted>/vendor/github.com/sourcegraph/conc/panics/panics.go:23 +0x70
  github.com/sourcegraph/conc.(*WaitGroup).Go.func1()
      <redacted>/vendor/github.com/sourcegraph/conc/waitgroup.go:32 +0x84

The reason is https://github.com/pb33f/doctor/blob/main/model/high/base/foundation.go#L306

      func (f *Foundation) AddEdge(edge *Edge) {
	if f == nil {
		return
	}
	if edge == nil {
		return
	}
	if f.Edges == nil {
		f.Edges = []*Edge{edge}
	} else {
		f.Edges = append(f.Edges, edge)
	}
}

does not take a lock on appending to f.Edges using the built in struct Mutex .

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.