mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-24 20:24:05 -08:00
fix(HTTP Request Node): Require parameter with filled name and value to avoid infinite loop (#8454)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <netroy@users.noreply.github.com> Co-authored-by: Elias Meire <elias@meire.dev>
This commit is contained in:
parent
ca75744c7f
commit
3128dca1fa
|
@ -1044,12 +1044,14 @@ export class HttpRequestV3 implements INodeType {
|
|||
name: 'name',
|
||||
type: 'string',
|
||||
default: '',
|
||||
placeholder: 'e.g page',
|
||||
},
|
||||
{
|
||||
displayName: 'Value',
|
||||
name: 'value',
|
||||
type: 'string',
|
||||
default: '',
|
||||
hint: 'Use expression mode and $response to access response data',
|
||||
},
|
||||
],
|
||||
},
|
||||
|
@ -1661,11 +1663,34 @@ export class HttpRequestV3 implements INodeType {
|
|||
if (pagination.paginationMode === 'updateAParameterInEachRequest') {
|
||||
// Iterate over all parameters and add them to the request
|
||||
paginationData.request = {};
|
||||
pagination.parameters.parameters.forEach((parameter) => {
|
||||
const { parameters } = pagination.parameters;
|
||||
if (parameters.length === 1 && parameters[0].name === '' && parameters[0].value === '') {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
"At least one entry with 'Name' and 'Value' filled must be included in 'Parameters' to use 'Update a Parameter in Each Request' mode ",
|
||||
);
|
||||
}
|
||||
pagination.parameters.parameters.forEach((parameter, index) => {
|
||||
if (!paginationData.request[parameter.type]) {
|
||||
paginationData.request[parameter.type] = {};
|
||||
}
|
||||
paginationData.request[parameter.type]![parameter.name] = parameter.value;
|
||||
const parameterName = parameter.name;
|
||||
if (parameterName === '') {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`Parameter name must be set for parameter [${index + 1}] in pagination settings`,
|
||||
);
|
||||
}
|
||||
const parameterValue = parameter.value;
|
||||
if (parameterValue === '') {
|
||||
throw new NodeOperationError(
|
||||
this.getNode(),
|
||||
`Some value must be provided for parameter [${
|
||||
index + 1
|
||||
}] in pagination settings, omitting it will result in an infinite loop`,
|
||||
);
|
||||
}
|
||||
paginationData.request[parameter.type]![parameterName] = parameterValue;
|
||||
});
|
||||
} else if (pagination.paginationMode === 'responseContainsNextURL') {
|
||||
paginationData.request.url = pagination.nextURL;
|
||||
|
|
Loading…
Reference in a new issue