mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
⚡Improve auth error detection
This commit is contained in:
parent
010f819bb0
commit
2e41075fc8
|
@ -63,6 +63,7 @@ interface IResourceLocatorQuery {
|
||||||
message?: string;
|
message?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
httpCode?: string;
|
httpCode?: string;
|
||||||
|
stackTrace?: string;
|
||||||
};
|
};
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
}
|
}
|
||||||
|
@ -154,9 +155,26 @@ const selectedMode = computed(() => {
|
||||||
|
|
||||||
const isListMode = computed(() => selectedMode.value === 'list');
|
const isListMode = computed(() => selectedMode.value === 'list');
|
||||||
|
|
||||||
const hasPermissionError = computed(() =>
|
const hasCredentialError = computed(() => {
|
||||||
['401', '403'].includes(currentResponse.value?.errorDetails?.httpCode ?? ''),
|
const PERMISSION_ERROR_CODES = ['401', '403'];
|
||||||
);
|
// Some of our NodeAPIErrors just return 500 without any details,
|
||||||
|
// so checking messages and stack traces for permission errors
|
||||||
|
const NODE_API_AUTH_ERROR_MESSAGES = [
|
||||||
|
'NodeApiError: Authorization failed',
|
||||||
|
'NodeApiError: Unable to sign without access token',
|
||||||
|
'secretOrPrivateKey must be an asymmetric key when using RS256',
|
||||||
|
];
|
||||||
|
// Check if error stack trace contains permission error messages
|
||||||
|
const stackTraceContainsCredentialError = (currentResponse.value?.errorDetails?.stackTrace ?? '')
|
||||||
|
.split('\n')
|
||||||
|
.some((line) => NODE_API_AUTH_ERROR_MESSAGES.includes(line.trim()));
|
||||||
|
|
||||||
|
return (
|
||||||
|
PERMISSION_ERROR_CODES.includes(currentResponse.value?.errorDetails?.httpCode ?? '') ||
|
||||||
|
NODE_API_AUTH_ERROR_MESSAGES.includes(currentResponse.value?.errorDetails?.message ?? '') ||
|
||||||
|
stackTraceContainsCredentialError
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
const credentialsNotSet = computed(() => {
|
const credentialsNotSet = computed(() => {
|
||||||
if (!props.node) return false;
|
if (!props.node) return false;
|
||||||
|
@ -784,28 +802,31 @@ function removeOverride() {
|
||||||
@load-more="loadResourcesDebounced"
|
@load-more="loadResourcesDebounced"
|
||||||
>
|
>
|
||||||
<template #error>
|
<template #error>
|
||||||
<div
|
<div :class="$style.errorContainer" data-test-id="rlc-error-container">
|
||||||
v-if="currentResponse.errorDetails"
|
<n8n-text
|
||||||
:class="$style.error"
|
v-if="credentialsNotSet || currentResponse.errorDetails"
|
||||||
data-test-id="rlc-error-container"
|
color="text-dark"
|
||||||
>
|
align="center"
|
||||||
<n8n-text color="text-dark" align="center" tag="div" class="mb-3xs">
|
tag="div"
|
||||||
|
>
|
||||||
{{ i18n.baseText('resourceLocator.mode.list.error.title') }}
|
{{ i18n.baseText('resourceLocator.mode.list.error.title') }}
|
||||||
</n8n-text>
|
</n8n-text>
|
||||||
<n8n-text size="small">
|
<div v-if="currentResponse.errorDetails" :class="$style.errorDetails">
|
||||||
<span v-if="currentResponse.errorDetails.httpCode">
|
<n8n-text size="small">
|
||||||
{{ currentResponse.errorDetails.httpCode }} -
|
<span v-if="currentResponse.errorDetails.httpCode">
|
||||||
</span>
|
{{ currentResponse.errorDetails.httpCode }} -
|
||||||
{{ currentResponse.errorDetails.message?.split('-')[0]?.trim() }}
|
</span>
|
||||||
</n8n-text>
|
{{ currentResponse.errorDetails.message }}
|
||||||
<N8nNotice
|
</n8n-text>
|
||||||
v-if="currentResponse.errorDetails.description"
|
<N8nNotice
|
||||||
theme="warning"
|
v-if="currentResponse.errorDetails.description"
|
||||||
class="mt-s mb-s text-left"
|
theme="warning"
|
||||||
>
|
:class="$style.errorDescription"
|
||||||
{{ currentResponse.errorDetails.description }}
|
>
|
||||||
</N8nNotice>
|
{{ currentResponse.errorDetails.description }}
|
||||||
<div v-if="hasPermissionError" data-test-id="permission-error-link">
|
</N8nNotice>
|
||||||
|
</div>
|
||||||
|
<div v-if="hasCredentialError || credentialsNotSet" data-test-id="permission-error-link">
|
||||||
<a
|
<a
|
||||||
v-if="credentialsNotSet"
|
v-if="credentialsNotSet"
|
||||||
:class="$style['credential-link']"
|
:class="$style['credential-link']"
|
||||||
|
|
|
@ -140,15 +140,27 @@ $--mode-selector-width: 92px;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
.error {
|
.errorContainer,
|
||||||
|
.errorDetails {
|
||||||
|
display: flex;
|
||||||
|
gap: var(--spacing-s);
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.errorContainer {
|
||||||
width: 80%;
|
width: 80%;
|
||||||
word-break: normal;
|
align-items: center;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
color: var(--color-text-base);
|
}
|
||||||
|
|
||||||
|
.errorDescription {
|
||||||
|
text-align: left;
|
||||||
|
margin: 0;
|
||||||
|
word-break: normal;
|
||||||
}
|
}
|
||||||
|
|
||||||
.credential-link {
|
.credential-link {
|
||||||
font-size: 12px;
|
font-size: var(--font-size-2xs);
|
||||||
}
|
}
|
||||||
|
|
||||||
.openResourceLink {
|
.openResourceLink {
|
||||||
|
|
Loading…
Reference in a new issue