usharerose commented on code in PR #3638:
URL: 
https://github.com/apache/incubator-devlake/pull/3638#discussion_r1011299692


##########
plugins/dbt/tasks/convertor.go:
##########
@@ -119,8 +119,10 @@ func DbtConverter(taskCtx core.SubTaskContext) 
errors.Error {
                dbtExecParams = append(dbtExecParams, "--vars")
                dbtExecParams = append(dbtExecParams, string(jsonProjectVars))
        }
-       dbtExecParams = append(dbtExecParams, "--select")
-       dbtExecParams = append(dbtExecParams, models...)
+       if models != nil {

Review Comment:
   Hi, @mindlesscloud . Agree with your point that need to handle the status 
when the slice is empty.
   
   But it is also possible that `models` is null when [not declaring 
`selectedModels` in `dbt` 
Options](https://github.com/apache/incubator-devlake/blob/6c5262e12f9b01f462971fea77808ce7442ed2ee/plugins/dbt/dbt.go#L54-L68).
 So I guess the condition should be `models != nil && len(models) > 0`.
   
   I have tested with above two scenarios based on current implementation (`if 
models != nil`).
   - When declaring `selectedModels` with empty slice value, there is only 
variable flag `--select` but no values in the command which should be handled 
by `len(models) > 0`
   ```
   time="2022-11-02 06:54:59" level=info msg=" [pipeline service] [pipeline 
#63] [task #71] [dbt] [DbtConverter] dbt run script: %!(EXTRA 
*exec.Cmd=/usr/bin/dbt run --project-dir /app/demo_proj --vars {"ids":["1"]} 
--select)"
   
   time="2022-11-02 06:55:03" level=error msg=" [task service] task failed
        caused by: Error running task 71.
        Wraps: (2) subtask DbtConverter ended unexpectedly
        Wraps: (3)
        Error types: (1) *hintdetail.withDetail (2) *hintdetail.withDetail (3) 
*errors.errorString"
   time="2022-11-02 06:55:03" level=error msg=" [pipeline service] [pipeline 
#63] run tasks failed
        caused by: Error running task 71."
   ```
   - When not declaring `selectedModels` in `dbt` options, there is no 
`--select` related in the command which is expected
   ```
   time="2022-11-02 06:53:44" level=info msg=" [pipeline service] [pipeline 
#62] [task #70] [dbt] [DbtConverter] dbt run script: %!(EXTRA 
*exec.Cmd=/usr/bin/dbt run --project-dir /app/demo_proj --vars {"ids":["1"]})"
   time="2022-11-02 06:53:48" level=info msg=" [pipeline service] [pipeline 
#62] [task #70] [dbt] [DbtConverter] 06:53:48  Running with dbt=1.3.0"
   ...
   ```



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