vscode-github-actions
vscode-github-actions copied to clipboard
Context access might be invalid: strategy
Describe the bug Many invalid instances of Context access might be invalid throughout a workflow file.
To Reproduce Steps to reproduce the behavior:
- Create a workflow with a job:
jobs:
dump_contexts_to_log:
runs-on: [self-hosted, light]
steps:
- name: Dump GitHub context
id: github_context_step
run: echo '${{ toJSON(github) }}'
- name: Dump job context
run: echo '${{ toJSON(job) }}'
- name: Dump steps context
run: echo '${{ toJSON(steps) }}'
- name: Dump runner context
run: echo '${{ toJSON(runner) }}'
- name: Dump strategy context
run: echo '${{ toJSON(strategy) }}'
- name: Dump matrix context
run: echo '${{ toJSON(matrix) }}'
- name: Dump vars context
run: echo '${{ toJSON(vars) }}'
Expected behavior
Such a job successfully dumps contexts such as strategy
yet the this plugin is flagging it as might be invalid.
Extension Version
v0.25.4
Additional context I have 21 of these types of warnings and not a single one of them is accurate. This is very distracting when trying to resolve legitimate issues in one's workflow file(s).
@brianjmurrell Could you please also include a screenshot of where the warnings are specifically? Thanks!
Really? Not sure how much value this adds to the ticket but here it is:
Thanks, we were trying to verify which contexts were being highlighted as warning. Looks like both the strategy and matrix contexts aren't being recognized within steps
Here is a repro:
Initial observations:
Hovering over run
shows strategy and matrix as supported contexts, so the error highlighting is unexpected.
Possibly a bug propagating context to the value for the run key
Have the same problem with v.0.25.7
I have the same problem with env
context. I am setting the environment variables in a previous step
I saw this as well. Restarting VSCode resolved the issue at least once for me.
I have the same problem with secrets
context
For the initial workflow file given in https://github.com/github/vscode-github-actions/issues/113#issue-1666276879, the errors disappear once a jobs.<job_id>.strategy
is added (tested with v0.25.7):
Without strategy |
With strategy |
---|---|
Also I find the contexts strategy
and matrix
are indeed supported (for some time) in schema for jobs.<job_id>.steps[*].run
, see
- https://github.com/actions/languageservices/blob/d7ae6f88f119e981692e43852d36c62118b7ec7f/workflow-parser/src/workflow-v1.0.json#L2021-L2039 and
- https://github.com/actions/languageservices/blob/main/workflow-parser/src/workflow-v1.0.json#L2471-L2487
I have the same problem with
secrets
context
I did too, but a restart solved it. At least once, as @G-Ke said :-)
Is there a fix for this yet as it is really annoying having all these errors when it isn't an issue.
@BertelBB https://github.com/github/vscode-github-actions/issues/113#issuecomment-1572081368 is a different problem, this ticket is specifically about strategy
which is fairly new. How you set env
context properties will vary and it wouldn't shock me if this add-on can't handle them, but the fix would be very different.