Skip to content

Env vars not processed correctly when used in a function URI #307

@bvandewe

Description

@bvandewe

What happened:

A workflow fails to run an action for which the function URI includes an environment variable in its definition.

Function definition

{
      "name": "create-lds-session",
      "operation": "${ \"\\(.environmentVariables.LAB_BASE_URL)/static/web/oas.yml#create-reservations-v3-lab_session-session\" }",
      "type": "rest",
      "authRef": "lds-basic"
    }

Worker's log

[23:15:16] info: Synapse.Worker.Services.Processors.OpenApiFunctionProcessor[0]
      Initializing activity '9f6685e1-205e-43f0-b55e-9b1d61c5168d' (type: 'Action')...
[23:15:16] warn: Synapse.Worker.Services.Processors.OpenApiFunctionProcessor[0]
      An error occured while executing the activity '9f6685e1-205e-43f0-b55e-9b1d61c5168d' (type: 'Action')/r/nDetails:/r/nSystem.UriFormatException: Invalid URI: The format of the URI could not be determined.
         at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
         at System.Uri..ctor(String uriString)
         at Synapse.Worker.Services.Processors.OpenApiFunctionProcessor.InitializeAsync(CancellationToken cancellationToken) in /src/src/apps/Synapse.Worker/Services/Processors/OpenApiFunctionProcessor.cs:line 148
[23:15:16] warn: Synapse.Worker.Services.Processors.OperationStateProcessor[0]
      An error occured while executing the activity '988c200b-fb86-402b-99c9-d6772cee3182' (type: 'State')/r/nDetails:/r/nSystem.UriFormatException: Invalid URI: The format of the URI could not be determined.
         at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
         at System.Uri..ctor(String uriString)
         at Synapse.Worker.Services.Processors.OpenApiFunctionProcessor.InitializeAsync(CancellationToken cancellationToken) in /src/src/apps/Synapse.Worker/Services/Processors/OpenApiFunctionProcessor.cs:line 148
[23:15:16] warn: Synapse.Worker.Services.WorkflowRuntime[0]
      An error occured while executing the workflow instance: System.UriFormatException: Invalid URI: The format of the URI could not be determined.
         at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind, UriCreationOptions& creationOptions)
         at System.Uri..ctor(String uriString)
         at Synapse.Worker.Services.Processors.OpenApiFunctionProcessor.InitializeAsync(CancellationToken cancellationToken) in /src/src/apps/Synapse.Worker/Services/Processors/OpenApiFunctionProcessor.cs:line 148
[23:15:16] info: Microsoft.Hosting.Lifetime[0]
      Application is shutting down...

The environment variable is correctly set in the state data when the worker calls the function.

  "environmentVariables": {
    "A_BASE_URL": "https://portal-stg.ccie.cisco.com",
    "B_BASE_URL": "https://ccie-folder.ccie.cisco.com",
    "LAB_BASE_URL": "https://lds-stg.ccie.cisco.com",
    ...etc...
  }

What you expected to happen:

The worker used to parse the URI (that includes an env var) correctly (i.e. this worked before 0.3.0).

How to reproduce it:

Just define a function where the URI includes a JQ expression with a variable (whose value is set at runtime).

Anything else we need to know?: This worked fine before 0.3.0.

Environment: All

Metadata

Metadata

Assignees

Labels

app: apiConcerns the APIapp: runnerConcerns the Runnerpriority: highIndicates a high priority issuetype: bugSomething isn't workingweight: 2An issue with a low development impact

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions