Skip to content

Conversation

@dgellow
Copy link
Member

@dgellow dgellow commented Jan 16, 2025

See https://apitools.dev/json-schema-ref-parser/docs/#circular-refs.

That fixes the circular ref hangs we've seen with https://github.com/stainless-sdks/wand-demo-python/actions/runs/12808284439/job/35710674735 timing out after 6h.

Why I think that change is safe:

  • The current code is (in short) decycle(dereference(specFile)), resulting in a loop. My change is decycle(bundle(specFile)). Here decycle is from @stoplight/json.
  • Reading feat: add decycle method stoplightio/json#81, I understand that decycle(dereference()) seems to be equivalent to bundle(), likely implemented before bundle() existed. So decycle(bundle()) should be pretty safe. I suspect the call to decycle is redundant?

But I would be happy to get a review here.

@dgellow dgellow requested a review from RobertCraigie January 16, 2025 20:03
Copy link
Member

@RobertCraigie RobertCraigie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know too much about the internals of the ref parser but your logic seems sound to me.

Would recommend testing this against our codegen before merging, either by just running things locally or getting it setup in CI

@dgellow
Copy link
Member Author

dgellow commented Jan 17, 2025

I'm seeing the following issue on some endpoints:

     │  E   acme.InternalServerError: Error code: 500 - {'type': 'https://stoplight.io/prism/errors#UNKNOWN', 'title': 'Invalid reference token: __bundled__', 'status': 500, 'detail': ''}

Not clear why :s

I will wait before merging.

@dgellow dgellow changed the title fix: parse spec using ref-parser bundle() to handle circular refs [WIP] fix: parse spec using ref-parser bundle() to handle circular refs Jan 17, 2025
@dgellow dgellow marked this pull request as draft January 17, 2025 14:02
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.

2 participants