kestra-io / kestra

:zap: Workflow Automation Platform. Orchestrate & Schedule code in any language, run anywhere, 500+ plugins. Alternative to Zapier, Rundeck, Camunda, Airflow...
https://kestra.io
Apache License 2.0
13.1k stars 1.15k forks source link

API response includes double slash #6041

Open wrussell1999 opened 20 hours ago

wrussell1999 commented 20 hours ago

Describe the issue

When I executed a flow using the API, I got a response with a URL to Kestra that contained two slashes when only one was needed.

Flow:

id: hello_world
namespace: company.team

inputs:
  - id: greeting
    type: STRING
    defaults: hey

tasks:
  - id: hello
    type: io.kestra.plugin.core.log.Log
    message: "{{ inputs.greeting }}"

API Request made in the terminal:

curl -X POST http://localhost:8084/api/v1/executions/company.team/hello_world

Response given:

{
    "id": "6gTABm82mx5li7tHkgqyNU",
    "namespace": "company.team",
    "flowId": "hello_world",
    "flowRevision": 10,
    "inputs": {
        "greeting": "hey"
    },
    "labels": [
        {
            "key": "system.correlationId",
            "value": "6gTABm82mx5li7tHkgqyNU"
        }
    ],
    "state": {
        "current": "CREATED",
        "histories": [
            {
                "state": "CREATED",
                "date": "2024-11-21T16:35:36.815338221Z"
            }
        ],
        "duration": 0.012298625,
        "startDate": "2024-11-21T16:35:36.815338221Z"
    },
    "originalId": "6gTABm82mx5li7tHkgqyNU",
    "deleted": false,
    "metadata": {
        "attemptNumber": 1,
        "originalCreatedDate": "2024-11-21T16:35:36.815378387Z"
    },
    "url": "http://localhost:8084//ui/executions/company.team/hello_world/6gTABm82mx5li7tHkgqyNU"
}

Specifically the bottom line url has two / after the server URL. It should be: "url": "http://localhost:8084/ui/executions/company.team/hello_world/6gTABm82mx5li7tHkgqyNU"

Should be a quick fix, and doesn't stop it working - just a minor bug.

Environment

benjoEK1337 commented 18 hours ago

hey. The code implementation takes the URL specified in the configuration files (application-{env}.yml or any other way to provide the value) and concats the "/ui" + the rest of the path to that URL. This could be fixed in the code by removing the slash if specified or to tell users to specify the URL without the slash at the end.

Here is the code creating the final URL:

` private URI executionUrl(Execution execution) { return URI.create(kestraUrl.orElse("") + "/ui" + (execution.getTenantId() != null ? "/" + execution.getTenantId(): "")

where kestraUrl is fetched from configuration:

@Value("${kestra.url}") private Optional<String> kestraUrl;

So, did you maybe specify in your application-local.yml or anywhere else the environment variable kestra.url as: "http://localhost:8084/"?

@loicmathieu what do you think?