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

Invalid Spec Leads to Error Without Init Callback #690

Closed
rosshardy opened this issue Oct 26, 2018 · 13 comments
Closed

Invalid Spec Leads to Error Without Init Callback #690

rosshardy opened this issue Oct 26, 2018 · 13 comments

Comments

@rosshardy
Copy link

Hello. In ReDoc 2.0.0-alpha.40 when generating ReDoc from a YAML file with a path with an empty tag (only the hyphen) ReDoc results in a "Something went wrong..." page with the below stack trace. The callback provided to init() is not invoked, so the surrounding application cannot recover from the error.

slugify: string argument expected
Stack trace
Error: slugify: string argument expected
    at t (http://localhost:9000/scripts/redoc.standalone.js:52:44272)
    at ae (http://localhost:9000/scripts/redoc.standalone.js:99:16985)
    at new e (http://localhost:9000/scripts/redoc.standalone.js:99:38568)
    at Function.e.getTagsItems (http://localhost:9000/scripts/redoc.standalone.js:99:51355)
    at Function.e.buildStructure (http://localhost:9000/scripts/redoc.standalone.js:99:50551)
    at new <anonymous> (http://localhost:9000/scripts/redoc.standalone.js:99:38384)
    at new e (http://localhost:9000/scripts/redoc.standalone.js:105:28591)
    at t.makeStore (http://localhost:9000/scripts/redoc.standalone.js:99:60285)
    at t.render (http://localhost:9000/scripts/redoc.standalone.js:99:61129)
    at Ai (http://localhost:9000/scripts/redoc.standalone.js:68:62703)

ReDoc Version: 2.0.0-alpha.40 
Commit: 8f7fccc
@RomanHotsiy
Copy link
Member

(only the hyphen)

is not an empty tag. It is equivalent to:

- null

So this is not valid spec as tags should be an array of string

image

To fix your spec you can use empty string:

- ""

@rosshardy
Copy link
Author

rosshardy commented Nov 5, 2018

@RomanGotsiy The issue is not the validity of the spec. The issue is that there is no way to recover from this in a solution leveraging ReDoc because the callback on init() is not honored. The ReDoc documentation says that the callback is called in the cases of an error, but in this case it is not.

@rosshardy rosshardy changed the title Empty Tag Leads to Error Without Init Callback Invalid Spec Leads to Error Without Init Callback Nov 5, 2018
@RomanHotsiy RomanHotsiy reopened this Nov 5, 2018
@RomanHotsiy
Copy link
Member

@rosshardy ahh, got it. Sorry.
Reopening.

@rosshardy
Copy link
Author

For additional context of the use case: we are trying to build a VSCode plugin which previews specs real-time as they are being built out or modified. However when the user edits tags and clears the tag out, the preview bombs out and there's no apparent way to recover ReDoc after the user corrects the spec.

@RomanHotsiy
Copy link
Member

For additional context of the use case: we are trying to build a VSCode plugin which previews specs real-time as they are being built out or modified.

😲This sounds super exciting! Is there any chance I can take a sneak peek of it?

I will look into the issue ASAP (most likely tomorrow morning).

@rosshardy
Copy link
Author

At the current time we are not permitted by our company to open source our efforts, however we would like to contribute it back to the community so others can benefit from it as we benefit from much open-source. We are working on changing our company's position on this. If that happens, we would be happy to share it.

Thank you for looking into it promptly!

@RomanHotsiy
Copy link
Member

Fixed! Will be released in the upcoming alpha.

At the current time we are not permitted by our company to open source our efforts

Could you at least share a screenshot or a gif of it with me privatelly? E.g. DM on twitter. I'm super curious 🤓

@rosshardy
Copy link
Author

Yes. E-mailed it to you. Thanks again for the prompt turnaround!

@rosshardy
Copy link
Author

@RomanGotsiy any estimate when the next alpha build will be released? Thank you.

@RomanHotsiy
Copy link
Member

Will be released early this week.

@rosshardy
Copy link
Author

Will be released early this week.

Will the release be coming soon? Thanks!

@RomanHotsiy
Copy link
Member

@rosshardy Check out redoc@2.0.0-rc.0 or use redoc@next

@osamaramihafez
Copy link

Is there a reason this slugify error may occur inside of a json file? I've been looking for a while but I haven't found anything simlar to a hyphen without a string. The error message isn't very descriptive and I can't really figure out what's wrong.

Something went wrong...
slugify: string argument expected
Stack trace
Error: slugify: string argument expected
    at n (https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:49:77206)
    at fe (https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:100:21266)
    at new e (https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:106:25452)
    at Function.e.getTagGroupsItems (https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:106:27224)
    at Function.e.buildStructure (https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:106:26607)
    at new ra (https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:106:25186)
    at new e (https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:106:89534)
    at t.makeStore (https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:100:71303)
    at t.render (https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:100:72261)
    at Fa (https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js:72:69876)

ReDoc Version: 2.0.0-rc.53
Commit: 5c8524d

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants