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

Include stack trace in errors, Closes #5660 #5758

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

nicodecleyre
Copy link
Contributor

@nicodecleyre nicodecleyre commented Jan 5, 2024

While working on this, i could not get the trace errors higher then the handleRejectedODataPromise & the handleRejectedODataPromise functions. For the tests i had to stub the cli options 🤔 , don't know if there is another, better way

Closes #5660

@milanholemans
Copy link
Contributor

Thank you @nicodecleyre, we'll have a look at it ASAP!

@waldekmastykarz
Copy link
Member

How can we test how this works @nicodecleyre?

@nicodecleyre
Copy link
Contributor Author

nicodecleyre commented Jan 31, 2024

How can we test how this works @nicodecleyre?

I thought of: On the one hand by stubbing the debug option, on the other hand by mocking a stack error. Is there another, better way that you have in mind?

@waldekmastykarz
Copy link
Member

How can we test how this works @nicodecleyre?

I thought of: On the one hand by stubbing the debug option, on the other hand by mocking a stack error. Is there another, better way that you have in mind?

I meant more: how can we see it in action. Stubs and mocks are based on assumptions, but how can we confirm that these are correct? How can we use CLI to see how it's handled in practice?

@nicodecleyre
Copy link
Contributor Author

How can we test how this works @nicodecleyre?

I thought of: On the one hand by stubbing the debug option, on the other hand by mocking a stack error. Is there another, better way that you have in mind?

I meant more: how can we see it in action. Stubs and mocks are based on assumptions, but how can we confirm that these are correct? How can we use CLI to see how it's handled in practice?

Got it, during testing I deliberately entered an incorrect command. For this I have used spo lisitem set with a field that does not exist. In this case 'InvalidField'
image

Which result in an error witht a stack trace:
image

@waldekmastykarz
Copy link
Member

Thanks! I'll try that!

Copy link
Member

@waldekmastykarz waldekmastykarz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the returned exception, it's not really useful:

Error: AxiosError: Request failed with status code 400
    at settle (file:///Users/waldek/github/pnp/cli-microsoft365/node_modules/axios/lib/core/settle.js:19:12)
    at IncomingMessage.handleStreamEnd (file:///Users/waldek/github/pnp/cli-microsoft365/node_modules/axios/lib/adapters/http.js:589:11)
    at IncomingMessage.emit (node:events:530:35)
    at endReadableNT (node:internal/streams/readable:1696:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
    at Axios.request (file:///Users/waldek/github/pnp/cli-microsoft365/node_modules/axios/lib/core/Axios.js:45:41)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

The whole stack points to code that we don't own and which we can do nothing about. I suggest we keep looking for another solution which is more helpful.

waldekmastykarz

This comment was marked as duplicate.

@waldekmastykarz waldekmastykarz marked this pull request as draft February 18, 2024 16:23
@waldekmastykarz
Copy link
Member

Hey @nicodecleyre, are you still working on this?

@nicodecleyre
Copy link
Contributor Author

Hi @waldekmastykarz, I certainly am. I've done some research regarding another solution in every spare time I have, just haven't found it yet

@nicodecleyre
Copy link
Contributor Author

Hi @waldekmastykarz, I investigated this further but the stacktrace has no reference to the cli code files at any time, not even in the command.action.
I have also looked for npm modules that could help with this, but they always read from the stack trace, which has no reference to our code files to begin with.

I was wondering if we can formulate a solid solution to this question?

@waldekmastykarz
Copy link
Member

Thanks for looking into it @nicodecleyre. I wonder if it would help, if we caught exceptions in the CLI code and threw a new one, so that we can capture information from the CLI code which we control rather than the dependencies with which we can do nothing.

@nicodecleyre
Copy link
Contributor Author

Thanks for looking into it @nicodecleyre. I wonder if it would help, if we caught exceptions in the CLI code and threw a new one, so that we can capture information from the CLI code which we control rather than the dependencies with which we can do nothing.

A-Mazing, this could go through with it, throwing an error from handleRejectedODataJsonPromise or handleRejectedODataPromise. Thanks a thousand times Waldek!!:
image

@nicodecleyre nicodecleyre marked this pull request as ready for review April 13, 2024 22:14
@waldekmastykarz
Copy link
Member

This looks way more meaningful! I'll have a closer look at it asap. Great find! 🚀

src/Command.ts Outdated Show resolved Hide resolved
src/Command.ts Outdated Show resolved Hide resolved
src/Command.spec.ts Outdated Show resolved Hide resolved
@waldekmastykarz waldekmastykarz marked this pull request as draft April 20, 2024 12:53
@nicodecleyre nicodecleyre marked this pull request as ready for review April 29, 2024 16:08
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.

Include stack trace in errors
3 participants