mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
fix(Nextcloud Node): Throw an actual error if server responded with Fatal error (#8234)
## Summary Nextcloud and Yourls receiving response with OK status as string containing 'Fatal error', throw an actual error in such case  ## Related tickets and issues https://linear.app/n8n/issue/NODE-1035/nextcloud-and-yourls-throw-an-actual-error-if-server-responded-with
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import type { IExecuteFunctions, IHookFunctions } from 'n8n-workflow';
|
import { NodeOperationError, type IExecuteFunctions, type IHookFunctions } from 'n8n-workflow';
|
||||||
|
|
||||||
import type { OptionsWithUri } from 'request';
|
import type { OptionsWithUri } from 'request';
|
||||||
|
|
||||||
@@ -52,5 +52,18 @@ export async function nextCloudApiRequest(
|
|||||||
|
|
||||||
const credentialType =
|
const credentialType =
|
||||||
authenticationMethod === 'accessToken' ? 'nextCloudApi' : 'nextCloudOAuth2Api';
|
authenticationMethod === 'accessToken' ? 'nextCloudApi' : 'nextCloudOAuth2Api';
|
||||||
return this.helpers.requestWithAuthentication.call(this, credentialType, options);
|
|
||||||
|
const response = await this.helpers.requestWithAuthentication.call(this, credentialType, options);
|
||||||
|
|
||||||
|
if (typeof response === 'string' && response.includes('<b>Fatal error</b>')) {
|
||||||
|
throw new NodeOperationError(
|
||||||
|
this.getNode(),
|
||||||
|
"NextCloud responded with a 'Fatal error', check description for more details",
|
||||||
|
{
|
||||||
|
description: `Server response:\n${response}`,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,16 @@ export async function yourlsApiRequest(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (typeof response === 'string' && response.includes('<b>Fatal error</b>')) {
|
||||||
|
throw new NodeOperationError(
|
||||||
|
this.getNode(),
|
||||||
|
"Yourls responded with a 'Fatal error', check description for more details",
|
||||||
|
{
|
||||||
|
description: `Server response:\n${response}`,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new NodeApiError(this.getNode(), error as JsonObject);
|
throw new NodeApiError(this.getNode(), error as JsonObject);
|
||||||
|
|||||||
2387
test-results.json
Normal file
2387
test-results.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user