redocly-cli icon indicating copy to clipboard operation
redocly-cli copied to clipboard

feat: handle error if api does not exist

Open SmoliyY opened this issue 2 years ago • 2 comments

What/Why/How?

Add error handle in cases if definition does not exist. Previously cli throw native error Screenshot 2022-09-26 at 17 19 41

Also there was and issue if root of apis provided as link. See #849 and #850

Reference

Closes #849, #850

Testing

Screenshots (optional)

Example with run redocly lint resources/pets.yaml not-exist.yaml Screenshot 2022-09-28 at 18 21 50

Check yourself

  • [ ] Code is linted
  • [ ] Tested with redoc/reference-docs/workflows
  • [ ] All new/updated code is covered with tests

Security

  • [ ] Security impact of change has been considered
  • [ ] Code follows company security practices and guidelines

SmoliyY avatar Sep 27 '22 16:09 SmoliyY

Coverage report

St.:grey_question:
Category Percentage Covered / Total
🟡 Statements 73.56% 3367/4577
🟡 Branches 65.25% 1902/2915
🟡 Functions 66.09% 571/864
🟡 Lines 73.59% 3129/4252
Show files with reduced coverage 🔻
St.:grey_question:
File Statements Branches Functions Lines
🟢
... / config-resolvers.ts
84% 74.49% 100% 84.72%
🟢 core/src/index.ts 100% 100% 7.84% 100%
🟡
... / utils.ts
69.77% 38.46%
83.33% (-2.38% 🔻)
71.43%

Test suite run success

521 tests passing in 84 suites.

Report generated by 🧪jest coverage report action from 73edb03e1625aeb6ec0e0577b6f08bb6e8ff10ab

github-actions[bot] avatar Sep 27 '22 16:09 github-actions[bot]

Please check if the logic covers the extends functionality: https://redocly.com/docs/cli/configuration/#extends-list

tatomyr avatar Oct 03 '22 07:10 tatomyr

And check it covers the plugins paths too.

adamaltman avatar Oct 09 '22 18:10 adamaltman

And check it covers the plugins paths too.

Please check if the logic covers the extends functionality: https://redocly.com/docs/cli/configuration/#extends-list

This check do not handle both of those cases. We can add this check, but it depends if we want to proceed in cases if plugin or config does not exist. I think we should proceed with same behaviour as it is work now ( Throw error and stop executing but with more efficient error)

cc @adamaltman @tatomyr

SmoliyY avatar Nov 16 '22 15:11 SmoliyY

I believe we should also cover plugins and extends. To me there's sense to proceed with a config which is trying to extend from non-existing config or a plugin. I believe we should add errors for those cases as well.

tatomyr avatar Nov 21 '22 10:11 tatomyr

Yes, with a friendly error message.

adamaltman avatar Nov 21 '22 13:11 adamaltman