fix(core): Unsafe isAxiosError property access (no-changelog) (#8197)

## Summary

in some cases the actual error does not get returned. It is apparently
reproducible with the OpenAI node but will probably also be a bug and so
a problem in other nodes:


https://community.n8n.io/t/problem-in-node-openai-cannot-read-properties-of-undefined-reading-isaxioserror/34716/9

## Related tickets and issues


https://linear.app/n8n/issue/NODE-1028/actual-error-does-not-always-get-returned

## Review / Merge checklist
- [ ] PR title and summary are descriptive. **Remember, the title
automatically goes into the changelog. Use `(no-changelog)` otherwise.**
([conventions](https://github.com/n8n-io/n8n/blob/master/.github/pull_request_title_conventions.md))
- [ ] [Docs updated](https://github.com/n8n-io/n8n-docs) or follow-up
ticket created.
- [ ] Tests included.
> A bug is not considered fixed, unless a test is added to prevent it
from happening again.
   > A feature is not complete without tests.
This commit is contained in:
Michael Kret 2024-01-03 20:43:31 +02:00 committed by GitHub
parent 8a3c87f69c
commit edbc5bb59a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -235,7 +235,7 @@ export class RoutingNode {
let routingError = error as AxiosError;
if (error instanceof NodeApiError) routingError = error.cause as AxiosError;
if (error instanceof NodeApiError && error.cause) routingError = error.cause as AxiosError;
throw new NodeApiError(this.node, error as JsonObject, {
runIndex,