Skip to content

Commit 4c5b3d8

Browse files
Copilotsbrunner
andcommitted
Fix attribute parsing when missing from request with empty default
When an attribute is missing from the request and has an empty default value, throw ObjectMissingException instead of trying to parse with empty object. This prevents OneOf validation errors on missing required attributes. Co-authored-by: sbrunner <353872+sbrunner@users.noreply.github.com>
1 parent b50f676 commit 4c5b3d8

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

core/src/main/java/org/mapfish/print/attribute/ReflectiveAttribute.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.mapfish.print.parser.MapfishParser;
2626
import org.mapfish.print.parser.OneOf;
2727
import org.mapfish.print.parser.ParserUtils;
28+
import org.mapfish.print.wrapper.ObjectMissingException;
2829
import org.mapfish.print.wrapper.PArray;
2930
import org.mapfish.print.wrapper.PElement;
3031
import org.mapfish.print.wrapper.PObject;
@@ -440,6 +441,12 @@ public Object getValue(
440441
throw new IllegalArgumentException(message);
441442
}
442443
pValue = this.getDefaultValue();
444+
// If the attribute is missing from the request and has no meaningful default,
445+
// throw ObjectMissingException to let the framework handle it properly
446+
if (pValue != null && !pValue.keys().hasNext()) {
447+
throw new ObjectMissingException(
448+
requestJsonAttributes, attributeName);
449+
}
443450
}
444451
MapfishParser.parse(errorOnExtraParameters, pValue, value);
445452
return value;

0 commit comments

Comments
 (0)