pefernan opened a new issue, #7155:
URL: https://github.com/apache/incubator-kie/issues/7155
### Describe the bug
**Problem**
When a `REST` task in a BPMN process defines inputs whose names contain
hyphens — such as ### HEADER_content-type (an HTTP header) or `QUERY_max-size`
(a query parameter) — the code generator emits those names verbatim as Java
identifiers. Hyphens are not valid in Java identifiers, so the generated
`_TaskInput `class does not compile.
**Reproduction**
Process file: wrong-rest.bpmn
Task: `Rest Service Task (_AC96E123-B9FF-4B62-806B-381AE2FF3A8E)`
Relevant BPMN inputs (lines 32–33 of the BPMN):
```xml
<bpmn2:dataInput id="..." name="HEADER_content-type" drools:dtype="String"
... />
<bpmn2:dataInput id="..." name="QUERY_max-size" drools:dtype="String"
... />
```
Generated class:
`Objectvariableprocessns__AC96E123_B9FF_4B62_806B_381AE2FF3A8E_TaskInput.java`
Invalid generated code (will not compile):
```java
private java.lang.String QUERY_max-size; // '-' is not a valid
identifier char
private java.lang.String HEADER_content-type; // same issue
public java.lang.String getQUERY_max-size() { … }
public java.lang.String getHEADER_content-type() { … }
item.QUERY_max-size = (java.lang.String) params.get("QUERY_max-size");
item.HEADER_content-type = (java.lang.String)
params.get("HEADER_content-type");
````
**Expected Behaviour**
The code generator must sanitise task input/output names before using them
as Java identifiers. The canonical approach is to replace each hyphen (and any
other non-[A-Za-z0-9_$] character) with an underscore, while keeping the
original name as the key used in params.get(...) so the runtime mapping is
preserved.
Expected generated code:
```
private java.lang.String QUERY_max_size; // sanitised field name
private java.lang.String HEADER_content_type; // sanitised field name
public java.lang.String getQUERY_max_size() { … }
public java.lang.String getHEADER_content_type() { … }
// original name still used for runtime map lookup
item.QUERY_max_size = (java.lang.String) params.get("QUERY_max-size");
item.HEADER_content_type = (java.lang.String)
params.get("HEADER_content-type");
```
**Root Cause**
The `_TaskInput` (and likely `_TaskOutput`) code generator template does not
apply any identifier-sanitisation step when it writes field names, getter
names, setter names, or setter parameter names derived from BPMN
dataInput/dataOutput name attributes.
### Expected behavior
_No response_
### Actual behavior
_No response_
### How to Reproduce?
_No response_
### Output of `uname -a` or `ver`
_No response_
### Output of `java -version`
_No response_
### GraalVM version (if different from Java)
_No response_
### Kogito version or git rev (or at least Quarkus version if you are using
Kogito via Quarkus platform BOM)
_No response_
### Build tool (ie. output of `mvnw --version` or `gradlew --version`)
_No response_
### Additional information
_No response_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]