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

Exception stack trace in the Request output channel on failed assertion #338

Closed
alekdavis opened this issue Nov 2, 2024 · 2 comments
Closed

Comments

@alekdavis
Copy link

I don't know if I am missing some setting, but I can't figure out how to stop logging exception stack traces on assertion failures. Exception stack trace is generally used when an exception (unexpected error) occurs due to some code error and a failed assertion is not really an exception (unexpected error). Nor is it a result of a code error.

Failed assertions are expected and a stack trace of the extension is really not useful. In fact, it makes harder to see what assertions failed. For example, if a request fails, for every assertion I get about 20 lines of extension's exception stack trace, e.g.:

image

So, if a request has 10 failed assertions, there will be over 200 lines of stack trace code, which provide no useful info. The only thing I need to know what assertion condition was not met. I doubt that anyone would care on which line and in which method of the extension code the assertion failure was caught.

I though that maybe the stack trace was displayed for debug or trace log level, but my log level in httpyac.config.js is set to info:

image

Is there a way around it? Some VSCode setting maybe?

@AnWeber
Copy link
Owner

AnWeber commented Nov 3, 2024

Using logOutputChannels.useShort removes logging exception, but also removes logging response body. I remove outputting stacktrace in testresults for failed tests. I only output exception if it is in status errored

@alekdavis
Copy link
Author

alekdavis commented Nov 3, 2024

My favorite CLI feature is the ability to define different output for successful and failed tests. For successful tests, I only need to see the short message with test name, request URL, and assertions. For failed tests, it is handy to see the context (full request, full response, headers). It works great in CLI, but I have not figured out how or if I can accomplish the same in VSCode.

It would be really helpful because now, when I get a failed test, I need to find test details (request/response/headers), so I have to switch from the TEST RESULTS tab to the Request output log and search for the failed test information there, which can be a pain if a test run includes multiple tests (when we're done, our smoke test suites will have hundreds of tests). So, cross referencing between TEST RESULTS and Request output is useful (it's great the request/response info is available), but kind of a pain. If TEST RESULTS output can be configured to show different info for successes and failures like in CLI, it would make troubleshooting of failed tests easier.

Regarding stack trace, I wish there were an option to turn it off completely because it provides no useful information since it is a stack trace for the extension and I am not troubleshooting the extension. I understand that it can be handy for the extension developers, but for the end user, but there is nothing in the stack trace that I can use to help me fix the test or my REST API (if I am testing my own endpoints). It would only make sense to see stack trace of the extension code if I had a bug (syntax error or whatever) in my http file. Or maybe if the requests could not be made at all (due to network issue, like proxy, endpoint being down, wrong URL, cert validation failure, etc). But in a normal scenario, when the response comes back from an endpoint, whether with the expected on non-expected status code and successful or failed assertion, I do not need to see the extension code stack trace because (1) it makes to navigate the test results difficult and (2) it gives an impression that there is something wrong with my test code (when it is not).

The reason why I do not need to see the stack trace on the status code assertion failure is because if I expect a successful status code (say, 200) returned, but the endpoint errors out and returns 400 (or whatever 400-499 code), that is not an unusual scenario. The only info I need to see in this case is the call context (request, response, headers) to figure out what went wrong and the stack trace is not helping here. In fact, it is making it more difficult.

If there is no option to turn the stack trace off via a setting, maybe only show it in the highest log level (Debug?)? Or have is shown in the output Log channel (not really sure what the Log channel is for)? Or have it in the Console output channel (not sure how this one works, since sometimes I see Console output and sometimes I don't).

The point I'm trying to make is that I understand that the stack trace of the extension code should be available in some cases (when developing extension, or having bugs in http file, or on complete failure to make a request), but these cases are so rare that an option to not show it in TEST RESULTS and Request log channels would be very welcome.

P.S. I really want to thank you for continuing improving the extension and addressing the issues. Very much appreciated.

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

No branches or pull requests

2 participants