mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
🐛 Fix n8n's behavior for empty response bodies (#2246)
* Fixed n8n's behavior for empty response bodies * Correctly parsing empty bodies when expected output is a buffer
This commit is contained in:
parent
389931da71
commit
62d1d69710
|
@ -387,15 +387,31 @@ async function proxyRequestToAxios(
|
||||||
axios(axiosConfig)
|
axios(axiosConfig)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
if (configObject.resolveWithFullResponse === true) {
|
if (configObject.resolveWithFullResponse === true) {
|
||||||
|
let body = response.data;
|
||||||
|
if (response.data === '') {
|
||||||
|
if (axiosConfig.responseType === 'arraybuffer') {
|
||||||
|
body = Buffer.alloc(0);
|
||||||
|
} else {
|
||||||
|
body = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
resolve({
|
resolve({
|
||||||
body: response.data,
|
body,
|
||||||
headers: response.headers,
|
headers: response.headers,
|
||||||
statusCode: response.status,
|
statusCode: response.status,
|
||||||
statusMessage: response.statusText,
|
statusMessage: response.statusText,
|
||||||
request: response.request,
|
request: response.request,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
resolve(response.data);
|
let body = response.data;
|
||||||
|
if (response.data === '') {
|
||||||
|
if (axiosConfig.responseType === 'arraybuffer') {
|
||||||
|
body = Buffer.alloc(0);
|
||||||
|
} else {
|
||||||
|
body = undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resolve(body);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
|
|
|
@ -896,7 +896,11 @@ export class WorkflowExecute {
|
||||||
// the `error` property.
|
// the `error` property.
|
||||||
for (const execution of nodeSuccessData!) {
|
for (const execution of nodeSuccessData!) {
|
||||||
for (const lineResult of execution) {
|
for (const lineResult of execution) {
|
||||||
if (lineResult.json.$error !== undefined && lineResult.json.$json !== undefined) {
|
if (
|
||||||
|
lineResult.json !== undefined &&
|
||||||
|
lineResult.json.$error !== undefined &&
|
||||||
|
lineResult.json.$json !== undefined
|
||||||
|
) {
|
||||||
lineResult.error = lineResult.json.$error as NodeApiError | NodeOperationError;
|
lineResult.error = lineResult.json.$error as NodeApiError | NodeOperationError;
|
||||||
lineResult.json = {
|
lineResult.json = {
|
||||||
error: (lineResult.json.$error as NodeApiError | NodeOperationError).message,
|
error: (lineResult.json.$error as NodeApiError | NodeOperationError).message,
|
||||||
|
|
Loading…
Reference in a new issue