eugenegujing opened a new issue, #9213:
URL: https://github.com/apache/texera/issues/9213
### What happened?
When a `PythonOperatorDescriptor`'s code generation throws, the operator's
whole code becomes a marker line:
```scala
//
common/workflow-operator/src/main/scala/org/apache/texera/amber/operator/PythonOperatorDescriptor.scala:29
s"#EXCEPTION DURING CODE GENERATION: ${ex.getMessage}"
```
`WorkflowCompiler` turns that marker back into a per-operator compilation
error by searching the code of every Python-based physical operator with an
unanchored regex:
```scala
//
common/workflow-compiler/src/main/scala/org/apache/texera/common/compiler/WorkflowCompiler.scala:306-311
val exceptionPattern = """#EXCEPTION DURING CODE GENERATION:\s*(.*)""".r
exceptionPattern.findFirstMatchIn(code).foreach { matchResult =>
val errorMessage = matchResult.group(1).trim
val error =
new RuntimeException(s"Operator is not configured properly:
$errorMessage")
```
The search runs over the operator's code wherever the marker text appears,
and for a Python UDF that code is the user's own script
(`PythonUDFOpDescV2.scala:139` and `:149` ship it as
`OpExecWithCode(codeWithParameters, "python")`; R UDFs are covered by the same
`isPythonBased` check, `PhysicalOp.scala:257`). A UDF that mentions the marker
text in a comment or a string is reported as a COMPILATION_ERROR, the physical
plan is dropped so the workflow cannot run, and the error message is the rest
of the user's comment line. The same happens for generated operators whose code
embeds a user-provided string containing the marker text.
Two smaller defects sit in the same marker:
- an exception without a message renders as the literal word `null`
(`Operator is not configured properly: null`);
- `(.*)` stops at the first line break, so only the first line of a
multi-line generation failure reaches the user.
### How to reproduce?
Reproduced on local `main` at 92e86d420 (build "dev").
1. Create a workflow with Text Input → Python UDF.
2. Paste this script into the Python UDF and select the operator. No run is
needed; the compile check runs on every edit.
```python
from pytexera import *
# NOTE: #EXCEPTION DURING CODE GENERATION: this is only a comment
class ProcessTupleOperator(UDFOperatorV2):
@overrides
def process_tuple(self, tuple_: Tuple, port: int) ->
Iterator[Optional[TupleLike]]:
yield tuple_
```
Observed: the run button reads "Invalid Workflow", and the Result Panel's
"Static Error" tab shows `COMPILATION_ERROR: Operator is not configured
properly: this is only a comment`. A copy of the workflow whose UDF is
identical except that line 3 (the comment) is removed compiles without the
error and its run button reads "Run".
Compiling the same plan through `WorkflowCompiler` directly gives:
```text
operatorIdToError = Map(PythonUDFOpDescV2-... ->
WorkflowFatalError(COMPILATION_ERROR, ..., "java.lang.RuntimeException:
Operator is not configured properly: this is only a comment", ...))
physicalPlan = None
```
### Version/Branch
1.4.0-incubating-SNAPSHOT (main)
### Commit Hash (Optional)
_No response_
### What browsers are you seeing the problem on?
_No response_
### Relevant log output
```shell
```
--
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]