leocook opened a new issue, #18216:
URL: https://github.com/apache/dolphinscheduler/issues/18216

   ### Search before asking
   
   - [x] I had searched in the 
[issues](https://github.com/apache/dolphinscheduler/issues?q=is%3Aissue) and 
found no similar issues.
   
   
   ### What happened
   
   
   I created a workflow with two SQL tasks. The upstream task outputs a 
parameter named `p1`, and the downstream task tries to reference it via a 
different parameter name `p2` (with value `${p1}`). The workflow fails with an 
exception.
   
   ```
   java.lang.IllegalArgumentException: No group with name {p1}
       at java.util.regex.Matcher.appendReplacement(Matcher.java:849)
       at java.util.regex.Matcher.replaceFirst(Matcher.java:1004)
       at 
org.apache.dolphinscheduler.plugin.task.sql.SqlTask.replaceOriginalValue(SqlTask.java:496)
   ```
   
   
   ### What you expected to happen
   
   The downstream task should correctly resolve `${p1}` to `111` and execute 
the SQL successfully.
   
   
   ### How to reproduce
   
   
   1. Create a workflow with two SQL tasks:
      - **sql_job_01** (upstream):
        - SQL: `select 111 as p1`
        - Output parameter: `p1` (direction: OUT, type: VARCHAR)
   
      - **sql_job_02** (downstream):
        - SQL: `select 222 as pp_!{p2}`
        - Input parameter: `p2` (direction: IN, type: VARCHAR, value: `${p1}`)
   
   2. Run the workflow
   
   ### Anything else
   
   After analyzing the code, I found two root causes:
   
   1. **VarPool not injected**: In 
`CuringParamsServiceImpl.paramParsingPreparation()`, step 6 only overrides 
parameters with the same name. Since the downstream task only has `p2` and not 
`p1`, the upstream VarPool value (`p1=111`) gets dropped.
   
   2. **Unsafe regex replacement**: `SqlTask.replaceOriginalValue()` uses 
`Matcher.replaceFirst(paramValue)` directly, which treats `$` as a regex group 
reference. When the unresolved placeholder `${p1}` contains `$`, it causes the 
regex to crash.
   
   ### Version
   
   dev
   
   ### Are you willing to submit PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)
   


-- 
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]

Reply via email to