Skip to content

Commit

Permalink
fix(batch-jobs): Add max length to configuration put step definition.
Browse files Browse the repository at this point in the history
A configuration cannot have more than 65535 characters, due to the database column `TEXT` definition. Adding the validation in the frontend permits to fail fast illegal requests without sending them to the backend. Also add check on backend.
  • Loading branch information
MDeLuise authored and Coduz committed Jul 17, 2023
1 parent de55b3a commit 0514a90
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ protected void refreshJobStepDefinition(GwtJobStepDefinition gwtJobStepDefinitio

textArea.setData(PROPERTY_TYPE, property.getPropertyType());
textArea.setData(PROPERTY_NAME, property.getPropertyName());
textArea.setMaxLength(65535);
jobStepPropertiesPanel.add(textArea);

if (property.getExampleValue() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ public JobStep create(JobStepCreator jobStepCreator) throws KapuaException {
ArgumentValidator.validateEntityName(jobStepCreator.getName(), "jobStepCreator.name");
ArgumentValidator.notNull(jobStepCreator.getJobStepDefinitionId(), "jobStepCreator.stepDefinitionId");

for (JobStepProperty jobStepProperty : jobStepCreator.getStepProperties()) {
Integer stepPropertyMaxLength = jobStepProperty.getMaxLength() != null ? jobStepProperty.getMaxLength() : 65535;
ArgumentValidator.lengthRange(jobStepProperty.getPropertyValue(), jobStepProperty.getMinLength(), stepPropertyMaxLength, "stepProperties[]." + jobStepProperty.getName());
}

if (jobStepCreator.getDescription() != null) {
ArgumentValidator.numRange(jobStepCreator.getDescription().length(), 0, 8192, "jobStepCreator.description");
}
Expand Down

0 comments on commit 0514a90

Please sign in to comment.