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

Mistaken type checking error #294

Closed
carlocab opened this issue Apr 20, 2023 · 7 comments
Closed

Mistaken type checking error #294

carlocab opened this issue Apr 20, 2023 · 7 comments

Comments

@carlocab
Copy link

I'm getting the following error which I believe to be mistaken:

object, array, and null values should not be evaluated in template with ${{ }} but evaluating the value of type array<any> [expression]

Here's a minimal reproducer.

The value of matrix.PR is, of course, an array. actionlint doesn't seem to recognise here that I will have a different job dispatched for each entry in the matrix.PR array, and each job will only see one value for matrix.PR.

@rhysd
Copy link
Owner

rhysd commented Jun 5, 2023

The error looks correct. The PR matrix value is an array because it is generated by filter syntax (github.event.workflow_run.pull_requests.*.number). An array value can not be embedded with ${{ }} syntax directly. I think probably what you want to do is:

- run: echo '${{ toJSON(matrix.PR) }}'

@carlocab
Copy link
Author

carlocab commented Jun 5, 2023

But matrix.PR is a scalar when evaluated inside the run: statement because of the way GitHub Actions handles matrix, so doing

- run: echo '${{ matrix.PR }}'

is not an error.

@rhysd
Copy link
Owner

rhysd commented Jun 5, 2023

But matrix.PR is a scalar when evaluated inside the run: statement

That's because the result of the filter syntax happened to be an array with a single element, am I correct? If the result contained two elements, the result would've been different.

@carlocab
Copy link
Author

carlocab commented Jun 5, 2023

That's because the result of the filter syntax happened to be an array with a single element, am I correct?

No, that is not correct.

If the result contained two elements, the result would've been different.

github.event.workflow_run.pull_requests.*.number can contain any number of elements. Regardless of the number of elements this array contains, in the context of run:, matrix.PR is always a scalar (conditional on the run: statement being reached).

Please see: https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs

@rhysd
Copy link
Owner

rhysd commented Jun 5, 2023

Oh, OK, I misread your workflow. Yes, since it is a row of matrix, the value should be scalar. Thanks for your explanation.

@rhysd rhysd closed this as completed in 6687a52 Jun 6, 2023
@carlocab
Copy link
Author

carlocab commented Jun 6, 2023

Thanks, @rhysd!

@rhysd
Copy link
Owner

rhysd commented Jun 6, 2023

@carlocab This was a bug of actionlint. Thank you for your report with the nice reproduction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants