dagu-org / dagu

Developer-friendly, minimalism Cron alternative, but with much more capabilities. It aims to solve greater problems.
https://dagu.readthedocs.io
GNU General Public License v3.0
1.63k stars 143 forks source link

error reading params while running it from web/API endpoint #648

Closed kriyanshii closed 3 months ago

kriyanshii commented 3 months ago

Here when i run the dag from web start button/api endpoint it saves 1st parameter as "param=value. and due to that it is unable to run the dag or use the param1. it is able to use all other params if there are more than one parameter defined.

The dag is like the following:


params: FOO=yes BAR=no
tags: Daily
steps:
  - name: "Initialize"
    command: "sleep 2"
  - name: "Copy TAB_1"
    description: "Extract data from TAB_1 to TAB_2"
    command: echo $FOO
    depends:
      - "Initialize"
  - name: "Update TAB_2"
    description: "Update TAB_2"
    command: echo $BAR
    depends:
      - Copy TAB_1
handlerOn:
  exit:
    command: echo finished

here is the log: ?tab=& HTTP/1.1" from 127.0.0.1:43496 - 200 3930B in 2.968414ms 2024/08/05 20:24:59 Initialize finished 2024/08/05 20:24:59 start running: Copy TAB_1 2024/08/05 20:24:59 Copy TAB_1 finished 2024/08/05 20:25:00 start running: Update TAB_2 2024/08/05 20:25:00 Update TAB_2 finished 2024/08/05 20:25:00 onExit started 2024/08/05 20:25:00 schedule finished. 2024/08/05 20:25:00 onExit finished 2024/08/05 20:25:00 Summary -> +--------------------------------------+-------+---------------------+---------------------+----------+-----------------+-------+ | REQUESTID | NAME | STARTED AT | FINISHED AT | STATUS | PARAMS | ERROR | +--------------------------------------+-------+---------------------+---------------------+----------+-----------------+-------+ | 3cef7619-ab11-42e8-9044-6344609a1dcc | test1 | 2024-08-05 20:24:57 | 2024-08-05 20:25:00 | finished | "FOO=yes BAR=no | | +--------------------------------------+-------+---------------------+---------------------+----------+-----------------+-------+ Details -> +---+--------------+---------------------+---------------------+----------+---------+-------+ | # | STEP | STARTED AT | FINISHED AT | STATUS | COMMAND | ERROR | +---+--------------+---------------------+---------------------+----------+---------+-------+ | 1 | Initialize | 2024-08-05 20:24:57 | 2024-08-05 20:24:59 | finished | sleep 2 | | | 2 | Copy TAB_1 | 2024-08-05 20:24:59 | 2024-08-05 20:24:59 | finished | echo | | | 3 | Update TAB_2 | 2024-08-05 20:25:00 | 2024-08-05 20:25:00 | finished | echo no | | +---+--------------+---------------------+---------------------+----------+---------+-------+

kriyanshii commented 3 months ago

it seems like when frontend sends run request along with the params, it contains " with name and value. and here no provision to remove " from the params name. it failed. if it added. it should work smoothly.

        if strings.HasPrefix(name, `"`) || strings.HasPrefix(value, "`") {
            if strings.HasPrefix(name, `"`) {
                name = strings.Replace(name, `"`, "", -1)
                // log.Print("inside valeu", name)
                name = strings.ReplaceAll(name, `\"`, `"`)
            }
        }

simply add this to parser.go

yohamta commented 3 months ago

@kriyanshii Hello, thank you very much for filing the issue. I believe that the latest version does not reproduce the issue. Could you please update to v1.14.2 and see if it's fixed? Sorry for the inconvenience that might be caused by this.

kriyanshii commented 3 months ago

v1.14.1 had the issue ig.

kriyanshii commented 3 months ago

@yohamta thank you for the prompt response

ghansham commented 3 months ago

It is fixed in 1.14.2. Thanks

yohamta commented 3 months ago

Thank you so much for checking that is fixed! Closing the issue.