vscode-github-actions icon indicating copy to clipboard operation
vscode-github-actions copied to clipboard

Context access might be invalid: strategy

Open brianjmurrell opened this issue 1 year ago • 11 comments

Describe the bug Many invalid instances of Context access might be invalid throughout a workflow file.

To Reproduce Steps to reproduce the behavior:

  1. 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 avatar Apr 13 '23 11:04 brianjmurrell

@brianjmurrell Could you please also include a screenshot of where the warnings are specifically? Thanks!

KetchupOnMyKetchup avatar Apr 13 '23 14:04 KetchupOnMyKetchup

Really? Not sure how much value this adds to the ticket but here it is:

image

brianjmurrell avatar Apr 13 '23 14:04 brianjmurrell

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: Screenshot 2023-04-13 at 4 59 57 PM

Initial observations:

Hovering over run shows strategy and matrix as supported contexts, so the error highlighting is unexpected. Screenshot 2023-04-13 at 5 04 03 PM

Possibly a bug propagating context to the value for the run key

elbrenn avatar Apr 13 '23 21:04 elbrenn

Have the same problem with v.0.25.7

migmit avatar Jun 01 '23 00:06 migmit

I have the same problem with env context. I am setting the environment variables in a previous step

image

BertelBB avatar Jun 01 '23 13:06 BertelBB

I saw this as well. Restarting VSCode resolved the issue at least once for me.

G-Ke avatar Jun 06 '23 05:06 G-Ke

I have the same problem with secrets context

luis-guimaraes-exoawk avatar Jun 06 '23 09:06 luis-guimaraes-exoawk

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
image image

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

muzimuzhi avatar Jun 06 '23 13:06 muzimuzhi

I have the same problem with secrets context

I did too, but a restart solved it. At least once, as @G-Ke said :-)

kjeldahl avatar Jun 16 '23 15:06 kjeldahl

Is there a fix for this yet as it is really annoying having all these errors when it isn't an issue.

adambirds avatar Aug 10 '23 23:08 adambirds

@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.

jsoref avatar Aug 10 '23 23:08 jsoref