Skip to content

Commit 5cecfd3

Browse files
committed
Fix PUT multipart check
1 parent 92d5fd9 commit 5cecfd3

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

workspace-server/src/main/java/gov/nasa/jpl/aerie/workspace/server/WorkspaceBindings.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -697,12 +697,13 @@ public void bulkPut(Context context) throws NoSuchWorkspaceException {
697697
}""";
698698

699699
// Get body
700-
if(!context.isMultipartFormData()) {
700+
if(!context.isMultipartFormData() || context.formParam("body") == null || context.formParam("files") == null) {
701701
context.status(400).json(new FormattedError("Invalid body format.",
702702
"""
703703
Expected body format is a multipart/form with two fields:
704704
"body", which contains the list of JSON objects describing where to put each file and directory
705705
"files", which contains all uploaded file contents"""));
706+
return;
706707
}
707708
try(final var bodyReader = Json.createReader(new StringReader(context.formParam("body")))){
708709
toUpload = bodyReader.readArray().getValuesAs(obj -> BulkPutItem.fromJson(obj.asJsonObject()));
@@ -711,11 +712,6 @@ public void bulkPut(Context context) throws NoSuchWorkspaceException {
711712
je,
712713
"Invalid body format. Expected body format is an array of JSON objects with the form:\n\n"+helpText));
713714
return;
714-
} catch (NullPointerException ne) {
715-
context.status(400).json(new FormattedError(
716-
ne,
717-
"Invalid body format. Expected body format is an array of JSON objects with the form:\n\n"+helpText));
718-
return;
719715
}
720716

721717
// Ensure that the user has specified at least one file or directory to upload

0 commit comments

Comments
 (0)