Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(HTTP Request Node): Require parameter with filled name and value to avoid infinite loop #8454

32 changes: 30 additions & 2 deletions packages/nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
],
},
Expand Down Expand Up @@ -1661,11 +1663,37 @@ 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) => {
if (
pagination.parameters.parameters.length === 1 &&
pagination.parameters.parameters[0].name === '' &&
pagination.parameters.parameters[0].value === ''
) {
michael-radency marked this conversation as resolved.
Show resolved Hide resolved
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;
Expand Down
Loading