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

Fix/extract annotations error handling #363

Merged

Conversation

nejclovrencic
Copy link
Contributor

@nejclovrencic nejclovrencic commented May 30, 2023

When running build, the for loop goes through each file and calls extractAnnotations and executes parsing logic. Any of this logic could throw, for example readFileSync inside extractAnnotations could throw. Currently, this fails the whole process.

This PR wraps everything inside the for loop in a try catch, and throws based on failOnError options.

This PR also replaced eslint-loader because it is deprecated and npm install on master branch currently fails, as eslint-loader does not support eslint v8.

Test plans

1

  1. Add a non-existing file to swagger build configuration
  2. Set failOnError: false
  3. Swagger generation shouldn't fail, if there are other files in the configuration

2

  1. Create a broken symlink (link to a non-existing file)
  2. Include that file in the build configuration
  3. Swagger generation shouldn't fail, if there are other files in the configuration

@daniloab
Copy link
Collaborator

@nejclovrencic thanks for the pull request. Some tests break. Can you check it, please?

@nejclovrencic nejclovrencic requested a review from daniloab May 30, 2023 14:15
@nejclovrencic
Copy link
Contributor Author

@daniloab tests should pass now, audit test was failing because of vulnerability in qs. I have updated express to the latest minor and body-parser to the latest major to fix the vulnerability. It's used only as dev dependency, so shouldn't have any effect in prod.

@nejclovrencic
Copy link
Contributor Author

@daniloab do you have any ETA when we can get this merged? Can we release a new minor version, including this fix?

@daniloab
Copy link
Collaborator

daniloab commented Jun 1, 2023

@daniloab do you have any ETA when we can get this merged? Can we release a new minor version, including this fix?

I would like to have a test plan for every merge change. Can we have someone to test your changes? https://dev.to/woovi/test-plan-driven-development-56a2

@nejclovrencic
Copy link
Contributor Author

@daniloab I have added the test plans in the PR description. I have tested the change, and will ask someone from my team to test this as well.

@daniloab
Copy link
Collaborator

daniloab commented Jun 1, 2023

@daniloab I have added the test plans in the PR description. I have tested the change, and will ask someone from my team to test this as well.

Sure, I agree. I mean tiny steps:

1. install the lib
2. try to build with this schema
3. see the error/ 3. see the succes

@shekharnwagh
Copy link

I can verify that it works as expected after following the test plan in the PR description. I've created a repo for testing - https://github.com/shekharnwagh/swagger-jsdoc-fix-test.

@daniloab
Copy link
Collaborator

daniloab commented Jun 2, 2023

I can verify that it works as expected after following the test plan in the PR description. I've created a repo for testing - shekharnwagh/swagger-jsdoc-fix-test.

this is really cool, thanks @shekharnwagh

@daniloab
Copy link
Collaborator

daniloab commented Jun 2, 2023

is this error expected with the pull request?
Screen Shot 2023-06-02 at 11 57 32

@nejclovrencic
Copy link
Contributor Author

@daniloabyes, this is expected. There is a broken symlink (src/app.js links to itself), so the library with the PR throws the error. If you change failOnError: false in index.js the code will run without any problems. You can observe similar behaviour even with cat, because the link is broken on purpose, for testing this PR.

> cat src/app.js
cat: src/app.js: Too many levels of symbolic links

> ls -la
total 8
drwxr-xr-x   4 nejclovrencic  staff  128 Jun  5 10:16 .
drwxr-xr-x  10 nejclovrencic  staff  320 Jun  5 10:18 ..
lrwxr-xr-x   1 nejclovrencic  staff    6 Jun  5 10:16 app.js -> app.js
-rw-r--r--   1 nejclovrencic  staff  552 Jun  5 10:16 router.js

@shekharnwagh
Copy link

shekharnwagh commented Jun 5, 2023

is this error expected with the pull request?

@daniloab I added that symlink to create a scenario where we can test the new failOnError flag.

@stale
Copy link

stale bot commented Aug 4, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Aug 4, 2023
@shekharnwagh
Copy link

do you have any ETA when we can get this merged? Can we release a new minor version, including this fix?

@daniloab Would it be possible to merge and release this.

@stale stale bot removed the wontfix label Aug 4, 2023
@daniloab daniloab merged commit 2325600 into Surnet:master Aug 4, 2023
@daniloab
Copy link
Collaborator

daniloab commented Aug 4, 2023

is this error expected with the pull request?

@daniloab I added that symlink to create a scenario where we can test the new failOnError flag.

can you check the audit flow, please? https://github.com/Surnet/swagger-jsdoc/actions/runs/5763184661/job/15624477586

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.

3 participants