Skip to content

Add limitation in the array of events for the endpoint of generate #227

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

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ public class RemremGenerateController {
@Value("${lenientValidationEnabledToUsers:false}")
private boolean lenientValidationEnabledToUsers;

@Value("${maxEventsOfInputArray:250}")
private int maxSize;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename the variable to be more expressive.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


public void setMaxSize(int maxSize) {
this.maxSize = maxSize;
}

public void setLenientValidationEnabledToUsers(boolean lenientValidationEnabledToUsers) {
this.lenientValidationEnabledToUsers = lenientValidationEnabledToUsers;
}
Expand Down Expand Up @@ -159,6 +166,14 @@ public ResponseEntity<?> generate(final String msgProtocol, final String msgType

if (inputData.isJsonArray()) {
JsonArray inputEventJsonArray = inputData.getAsJsonArray();

if (inputEventJsonArray.size() > maxSize) {
return createResponseEntity(HttpStatus.BAD_REQUEST, JSON_ERROR_STATUS,
"The number of events in the input array is exceeded the allowed limit of 250 events. " +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use real values, not hard-coded ones.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

"This issue occurred because the input array contains more than 250 events, which is not supported by the system. "
+ "To resolve this, please divide the events in to smaller arrays, ensuring each array contains no more than 250 events,"
+ "and try to generate them again. This limitation helps to maintain system performance and stability.");
}
for (JsonElement element : inputEventJsonArray) {
JsonObject generatedEvent = (processEvent(msgProtocol, msgType,
failIfMultipleFound, failIfNoneFound, lookupInExternalERs, lookupLimit,
Expand Down
5 changes: 4 additions & 1 deletion service/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,7 @@ event-repository.enabled: false
event-repository.url: http://<host>:<port>/<context-path-if-available>

# lenientValidationEnabledToUsers true will perform the validation only on mandatory fields, non-mandatory validation failures add into Eiffel message as property remremGenerateFailures
lenientValidationEnabledToUsers: false
lenientValidationEnabledToUsers: false

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maximum number of templates in array passed to /xxx endpoint. Please, replace xxx by real endpoint name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

#Maximum size of events in array is fetched from REMReM property and checked during publishing.
maxEventsOfInputArray: 250
Loading