Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(bug) fromJSON leading to a yaml unmarshal error #284

Closed
tzusman opened this issue Jun 19, 2020 · 15 comments · Fixed by #700 or #763
Closed

(bug) fromJSON leading to a yaml unmarshal error #284

tzusman opened this issue Jun 19, 2020 · 15 comments · Fixed by #700 or #763
Assignees
Labels
area/workflow Relating to workflow definitions kind/bug Something isn't working meta/resolved Issue has been fixed or valid solution has been provided (not workaround)

Comments

@tzusman
Copy link

tzusman commented Jun 19, 2020

This part of my GitHub Action workflow is confirmed to work on Github, but not through act:

strategy:
  matrix: ${{ fromJson(needs.deployments.outputs.deployments) }}
act -l
Error: yaml: unmarshal errors:
  line 153: cannot unmarshal !!str `${{ fro...` into map[string][]interface {}

The deployments output looks something like this:

[
  { "region": "us", "key": "value" },
  { "region": "eu", "key": "value2" }
]
@cplee cplee added area/workflow Relating to workflow definitions kind/bug Something isn't working labels Jun 23, 2020
@ssbarnea
Copy link

ssbarnea commented Jul 23, 2020

Error: yaml: unmarshal errors:
line 70: cannot unmarshal !!str `${{ mat...` into map[string]string
line 74: cannot unmarshal !!str `${{ mat...` into map[string]string

This is the first thing I got after reading about act and installing it, and that is more than an a month old. The error doesn't even mention the file causing the error! I had to guess.

I run it inside https://github.com/ansible/ansible-lint/blob/master/.github/workflows/tox.yml which does not even have any fromJson in it.

I hope someone looks over it because the act idea is brilliatn, but nobody wants a tool that crashes on first run.

@vecerek
Copy link

vecerek commented Aug 14, 2020

+1

@github-actions
Copy link
Contributor

Issue is stale and will be closed in 7 days unless there is new activity

@github-actions github-actions bot added the stale label Oct 14, 2020
@vecerek
Copy link

vecerek commented Oct 14, 2020

Bump

@ni4
Copy link

ni4 commented Oct 16, 2020

Got the same issue right after installing the act. Both error lines are like of the previous commenters:
env: ${{ matrix.env }}
Not to mention that everything run smoothly via GHA.

@cplee cplee removed the stale label Nov 8, 2020
@dsever
Copy link

dsever commented Nov 9, 2020

Any workaround?

This was referenced Nov 19, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2021

Issue is stale and will be closed in 7 days unless there is new activity

@github-actions github-actions bot added the stale label Jan 9, 2021
@plmercereau
Copy link

Well I'm still having this issue and it's a blocking one so I guess it shouldn't be closed

@ShayNehmad-RecoLabs
Copy link

This is also blocking for my workflow when working with the FromJson command to develop monorepo workflows:

    runs-on: ubuntu-20.04
    strategy:
      matrix:
        package: ${{ fromJson(needs.provide_packages_json.outputs.matrix) }}

Error:

❯ act -l
Error: yaml: unmarshal errors:
  line 88: cannot unmarshal !!str `${{ fro...` into []interface {}

@catthehacker
Copy link
Member

@tzusman @ShayNehmad-RecoLabs could any of you provide full workflow that I can debug on?

@ShayNehmad-RecoLabs
Copy link

@catthehacker My example is based on https://tomasvotruba.com/blog/2020/11/16/how-to-make-dynamic-matrix-in-github-actions/

@github-actions github-actions bot removed the stale label Jan 19, 2021
@github-actions
Copy link
Contributor

Issue is stale and will be closed in 14 days unless there is new activity

@github-actions github-actions bot added the stale label Feb 19, 2021
@lufia
Copy link
Contributor

lufia commented Feb 24, 2021

I think the cause of this error is that YAML parser expects the matrix: a map of array of empty interface. At parsing the workflow, the matrix: will not evaluate yet then the parser get an expression as a string. Therefore the parser cannot parse that workflow.

type Strategy struct {
	FailFast    bool                     `yaml:"fail-fast"`
	MaxParallel int                      `yaml:"max-parallel"`
	Matrix      map[string][]interface{} `yaml:"matrix"`
}
// https://github.com/nektos/act/blob/master/pkg/model/workflow.go#L76

Would change the Matrix field from map[string][]interface{} to interface{} and type cast it every use?

@github-actions github-actions bot removed the stale label Feb 25, 2021
@github-actions
Copy link
Contributor

Issue is stale and will be closed in 14 days unless there is new activity

@pablogs9
Copy link

+1

@catthehacker catthehacker self-assigned this May 23, 2021
@mergify mergify bot closed this as completed in #700 Jun 6, 2021
@catthehacker catthehacker added meta/resolved Issue has been fixed or valid solution has been provided (not workaround) and removed needs-work Extra attention is needed stale-exempt Exempt from stale labels Aug 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/workflow Relating to workflow definitions kind/bug Something isn't working meta/resolved Issue has been fixed or valid solution has been provided (not workaround)
Projects
None yet