fix(D-01): warn on non-object component config, deep-copy configs (RISK-001, RISK-002)
- Deep-copy JsonObject configs via deepCopy() before storing in the definition to prevent external mutation of the parsed JSON tree - Log a warning when a component config value is not a JsonObject, making misconfigured JSON easier to diagnose
This commit is contained in:
@@ -279,9 +279,17 @@ public final class DataDrivenItemParser {
|
|||||||
entry.getKey()
|
entry.getKey()
|
||||||
);
|
);
|
||||||
if (compType != null) {
|
if (compType != null) {
|
||||||
JsonObject config = entry.getValue().isJsonObject()
|
JsonObject config;
|
||||||
? entry.getValue().getAsJsonObject()
|
if (entry.getValue().isJsonObject()) {
|
||||||
: new JsonObject();
|
config = entry.getValue().getAsJsonObject().deepCopy();
|
||||||
|
} else {
|
||||||
|
LOGGER.warn(
|
||||||
|
"[DataDrivenItemParser] Component '{}' in item '{}' has non-object config, using defaults",
|
||||||
|
entry.getKey(),
|
||||||
|
fileId
|
||||||
|
);
|
||||||
|
config = new JsonObject();
|
||||||
|
}
|
||||||
componentConfigs.put(compType, config);
|
componentConfigs.put(compType, config);
|
||||||
} else {
|
} else {
|
||||||
LOGGER.warn(
|
LOGGER.warn(
|
||||||
|
|||||||
Reference in New Issue
Block a user