Cannot push existing Map containing key 'context'

Hello,
I’m looking for some guidance on how to best handle a reserved parameter name in Moqui.

I recently had to implement an API where one of the required request parameters was named context. However, this resulted in the following exception:

Internal error processing request: java.lang.IllegalArgumentException: Cannot push existing Map containing key ‘context’, reserved key

I was eventually able to work around the issue by modifying WebFacadeImpl (around lines 144–145). Before the parameters are pushed into the execution context, I check for the context key and rename it to parameterContext:

if ((contentType.contains(“application/json”) || contentType.contains(“text/json”))) {
try {
JsonNode jsonNode = ContextJavaUtil.jacksonMapper.readTree(bodyString)
if (jsonNode.isObject()) {
jsonParameters = ContextJavaUtil.jacksonMapper.treeToValue(jsonNode, Map.class)
} else if (jsonNode.isArray()) {
jsonParameters = [_requestBodyJsonList:ContextJavaUtil.jacksonMapper.treeToValue(jsonNode, List.class)] as Map<String, Object>
}

if (jsonParameters.containsKey(“context”)) { jsonParameters.put(“parameterContext”, jsonParameters.remove(“context”))
}
} catch (Throwable t) {
logger.error(“Error parsing HTTP request body JSON: ${t.toString()}”, t)
jsonParameters = [_requestBodyJsonParseError:t.getMessage()] as Map<String, Object>
}
// logger.warn(“=========== Got JSON HTTP request body: ${jsonParameters}”)
}

The workaround solved my problem by allowing the API to accept the incoming context parameter and replacing it to parameterContext internally before the body is added to the context stack.

My question is, Is there a cleaner way to handle this? I suspect I may have overlooked an existing solution for dealing with reserved parameter names, and I’d appreciate any suggestions or best practices if you have encountered a similar situation.

Thank you.