cve-bin-tool icon indicating copy to clipboard operation
cve-bin-tool copied to clipboard

aiohttp fails seem to violate quiet mode

Open terriko opened this issue 2 years ago • 1 comments

  • from #1427
FAILED test/test_cli.py::TestCLI::test_quiet_mode - aiohttp.client_exceptions...

When we have a network connection fail it looks like quiet mode breaks (at least, the test does). In the case of the pull request where this occurred it was not a related error, but we should probably fix it properly.

terriko avatar Oct 28 '21 23:10 terriko

To be more clear on what to do here:

What we want is for aiohttp exceptions to be caught in the code and translated into some sort of (silent) error condition for quiet_mode users. So you probably need a try .. raises block that then has cve-bin-tool immediately exit with an appropriate error and error number.

Testing will be a bit of a pain: you're trying to duplicate a loss of network in the middle of updating. You can disconnect your network while running tests to try it manually, but you'll likely need to do something with Mock to test your code in a more reproducible way.

terriko avatar Apr 14 '22 21:04 terriko

  • When trying locally, I'm having requests.exceptions.ConnectionError instead of aiohttp.client_exceptions.
  • similar to #2382 try/catch is working as expected. or again am I missing something? @terriko

inosmeet avatar Feb 05 '24 05:02 inosmeet

@Dev-Voldemort This issue was filed in 2021 so I won't be surprised if the message has changed -- we definitely are trying to switch towards using requests more often.

But yes, a try-catch is probably what's needed with the correct error type. And tests to avoid further failures of this type.

terriko avatar Feb 05 '24 22:02 terriko

I'll make a PR soon after the other one.

inosmeet avatar Feb 06 '24 13:02 inosmeet

does MirrorError: 39 from error_handler sounds like an appropriate error or do I make a new one? also, how should I go about for the test?

inosmeet avatar Feb 08 '24 13:02 inosmeet

If it's the mirror that's failing and the error will only happen during mirror network issues, yes, that would be fine. If it's maybe something else that failed then go ahead and make a new one to differentiate.

I honestly don't know the best way to write the test. Something with mock probably?

terriko avatar Feb 08 '24 15:02 terriko