fission / fission-workflows

Workflows for Fission: Fast, reliable and lightweight function composition for serverless functions
Apache License 2.0
371 stars 42 forks source link

Cannot return header fields with dash #247

Closed sebastianrosch closed 5 years ago

sebastianrosch commented 5 years ago

The workflow definition does not allow me to access header fields that contain a dash, like X-B3-Traceid. Workflow execution fails with parse error: Invalid literal at line 1, column 7

My workflow:

apiVersion: 1
output: ReturnTraceId
tasks:
  ReturnTraceId:
    run: compose
    inputs:
      invocationId: "{$.Invocation.Id}"
      traceId: "{$.Invocation.Inputs.headers.X-B3-Traceid}"

Workflow validation succeeds.

This is the output of $.Invocation, so the $.Invocation.Inputs.headers.X-B3-Traceid field exists.

{
    "CreatedAt": 1550063073697262000,
    "Id": "wi-7181aaf1-1ece-4de1-9b8b-0d8c0d70fb25",
    "Inputs": {
      "body": {
         ...
      },
      "default": {
      },
      "headers": {
        "Accept": "*/*",
        "Accept-Encoding": "gzip",
        "Connection": "close",
        "Content-Length": "132",
        "Content-Type": "application/json",
        "User-Agent": "curl/7.54.0",
        "X-B3-Sampled": "1",
        "X-B3-Spanid": "7d0a3b5cf1043d11",
        "X-B3-Traceid": "70d09604e9f38942ad351354bef2be5c"
        ...
      },
      "method": "POST",
      "query": {}
    }
}
erwinvaneyk commented 5 years ago

Hi @sebastianroesch - thanks for raising the issue. This might be a 'bug' in the javascript expression evaluator: it is an invalid field name in javascript. $.Invocation.Inputs.headers['X-B3-Traceid'] should work.

Regardless, it is indeed something that we should catch earlier on in validation 👍

sebastianrosch commented 5 years ago

$.Invocation.Inputs.headers['X-B3-Traceid'] works for me, thank you!