github / vscode-github-actions

GitHub Actions extension for VS Code
https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-github-actions
MIT License
488 stars 87 forks source link

"Context access might be invalid" warning thrown for repository variables and secrets #222

Open afefer opened 1 year ago

afefer commented 1 year ago

Describe the bug After upgrading to 0.25.8, a "Context access might be invalid" warning is thrown for all repository variables and secrets in the workflow file. Refreshing the secrets/vars in the extension has no effect.

Expected behavior Secrets/vars should not throw a "Context access might be invalid" warning.

Screenshots

image image

Extension Version v0.25.8

Additional context Add any other context about the problem here.

aschen-builder commented 1 year ago

Also seeing this issue still with the latest release.

Previous issues #47 #61 and #67 stated the issue would be fixed with the next release, but issue continues to persist into release v0.25.8 and the change log seems to make no mention of a fix being deployed.

moshest commented 1 year ago

Any update on this?

acharyasaagar commented 1 year ago

I still see this as well; the extension version is v0.25.8

evertonspader-tomtom commented 1 year ago

Seeing the same here constantly with v0.25.8

avh03 commented 1 year ago

Just wanted to confirm that the issue continues to persist in 0.25.8 (and it's feeling really annoying)

anthony9187 commented 1 year ago

also seeing this constantly in v0.25.8 with env variables, but not secrets

mickael-h commented 1 year ago

Same here. A bit annoying indeed 👍

Bohemus307 commented 1 year ago

Still persists kind of embarrassing for GH

enriquepevida commented 1 year ago

ah, i see this is an actual issue. i was going mad with this. Let´s hope it´s fixed soon.

felipesu19 commented 1 year ago

Yep, its a bug. Moved to triage. No ETA on a fix, if someone makes a PR to fix, I'm happy to review it.

PrimeTimeTran commented 1 year ago

I uninstalled, reinstalled and restarted VSCode and then the warnings went away. v0.25.8

techguydave commented 1 year ago

I was receiving this error after installing the extension. Simply running the "Developer: Reload Window" command fixed it for me without needing to reinstall. So far it hasn't seemed to return yet, at least for repo secrets.

japo32 commented 1 year ago

I was receiving this error after installing the extension. Simply running the "Developer: Reload Window" command fixed it for me without needing to reinstall. So far it hasn't seemed to return yet, at least for repo secrets.

I tried this but it came back :(

adambirds commented 1 year ago

Okay, at least in my instance, the issue seems to be because I have a setup like this:

organization/repo - Main repository. Secrets/vars are done on this.

myuser/repo - Fork which I do my work on before creating a merge to push to upstream/main. Therefore in actions, its thinks the vars/secrets don't exist because they existing the main repo not my fork. There should at least be a way of ignoring this specific error if this is the case.

larouxn commented 1 year ago

👋 Reporting in, still happening on v0.26.1.

There should at least be a way of ignoring this specific error if this is the case.

Agreed, there should at least be a # github-actions-extension ignore comment one can use.

gregalia commented 1 year ago

I get this warning for any environment variable exported in a previous step via echo "foo=bar" >>$GITHUB_ENV

v0.26.1

JoelYoung01 commented 1 year ago

I uninstalled, reinstalled and restarted VSCode and then the warnings went away. v0.25.8

This worked for me.

BertelBB commented 1 year ago

This seems to only happen when environment property is dynamic.

image

marano commented 1 year ago

I get this error for all of my secrets, am I missing something?

Screenshot 2023-09-01 at 07 48 23
budokans commented 1 year ago

Expected behavior Secrets/vars should not throw a "Context access might be invalid" warning.

I actually like this warning. Because our YAML file has no access to production environment variables when we're editing it, it's a nice reminder to double-check our variable names.

BertelBB commented 1 year ago

Expected behavior Secrets/vars should not throw a "Context access might be invalid" warning.

I actually like this warning. Because our YAML file has no access to production environment variables when we're editing it, it's a nice reminder to double-check our variable names.

That's one way of looking at it. I would say a more realistic view is that it will condition you to ignore the warnings which causes the opposite effect of what you described.

drewagentsync commented 1 year ago

I'm seeing this same behavior when pulling an output from a previous step through needs "Context access might be invalid". Is this being triggered by the value not being available to read because the previous step has not run? Just wondering as you'd think it could see the output it'd be pulling the value from is in the previous needed step.

qortex commented 1 year ago

I had this error on secrets. Turns out I wasn't properly signed in on github inside Vscode. Signing in and reloading fixed the issue.

lukesneeringer commented 1 year ago

I had this error on secrets. Turns out I wasn't properly signed in on github inside Vscode. Signing in and reloading fixed the issue.

How does one "sign in to GitHub inside VS Code"?

And I'd argue this is a bug regardless; if you're not signed in, then it should just assume all variables are fine, not spam you with spurious warnings.

hsyhhssyy commented 1 year ago

However, this will cause VSCode to color this folder yellow, override source control's color. I can't tell if any project is committed or not as all my project folders are alway marked yellow. I might forget to commit changes for that reason.

davearel commented 1 year ago

How does one "sign in to GitHub inside VS Code"?

Open the "github actions" extension side-panel and click "Sign in with Github".

Authenticating this extension with Github worked for me.

And I'd argue this is a bug regardless; if you're not signed in, then it should just assume all variables are fine, not spam you with spurious warnings.

I agree this is still a bug, but Instead of assuming all variables are correct (which could easily be mistaken for being a valid secret) it should indicate that secrets (and potentially other checks) cannot be verified until authenticated. This extension requires authentication for a lot of features.

MolotovCherry commented 1 year ago

Saw this error after installing and signing in. Uninstalled it and reinstalled it, and it worked fine after

tommyskott commented 1 year ago

I signed in to github after installing the extension and saw the secrets errors. I completely quit VS Code and re-opened it again and the secrets were no longer throwing any warnings. :)

davearel commented 1 year ago

I signed in to github after installing the extension and saw the secrets errors. I completely quit VS Code and re-opened it again and the secrets were no longer throwing any warnings. :)

Yeah, this happened to me too. I think I just clicked the "refresh current branch" button in the sidebar and the errors went away.

bemoche commented 1 year ago

Same here. Restarting VS Code after install and login fixed the issue for me!

beldougie commented 1 year ago

V0.26.2 - as long as you are logged in and have given access to the extension, make sure you execute Developer: Reload Window (or restart VSCode). I also had this issue until performing both these steps. Hope that helps someone.

wipe2238 commented 1 year ago

Didn't saw it mentioned, so... dumb workaround if anyone needs:

${{ fromJSON(toJSON(secrets)).MY_LITTLE_SECRET }}

Easy to restore proper syntax when/if fix comes.

wastu01 commented 1 year ago

v0.26.2 it does not work for me using Developer: Reload Window (or restart VSCode). Context access might be invalid: PERSONAL_TOKEN

veraposeidon commented 1 year ago

Here are my steps to resolve the warningContext access might be invalid: TOKEN:

  1. Install the GitHub Actions extension in VS Code.
  2. Open the GitHub Actions tab and ensure that you are logged in and have fetched the action info for your Git repository.
  3. In the SETTINGS section, verify the presence of the variables you have set under "Environments" and "Secrets".
  4. If the warning persists, try running "Refresh current branch" from the Command Palette. Alternatively, you can restart VS Code.

image

lbrealdev commented 1 year ago

Here are my steps to resolve the warningContext access might be invalid: TOKEN:

  1. Install the GitHub Actions extension in VS Code.
  2. Open the GitHub Actions tab and ensure that you are logged in and have fetched the action info for your Git repository.
  3. In the SETTINGS section, verify the presence of the variables you have set under "Environments" and "Secrets".
  4. If the warning persists, try running "Refresh current branch" from the Command Palette. Alternatively, you can restart VS Code.

image

Yeah, this worked for me, thanks for sharing.

I'm using Github Actions v0.26.2.

Cyberboss commented 1 year ago

This still happens with all dynamically generated environment variables and is pretty annoying image

andyslack commented 1 year ago

I'm seeing this on ${{ env.STORE_PATH }}

Screenshot 2023-10-04 at 12 00 39
iuritorres commented 12 months ago

Hey guys, i think some of you are forgetting to set the environment before setting environment variables...

With the Github Actions VSCode Extension (i really recommend to use this if you intend to keep using GitHub Actions), in the "GitHub Actions" tab in left sidebar menu, (ensure that you're already logged in with your GitHub account), you can see which environment you env-variable is:

In my case, TEST(Environment) > TESTEE (Variable) image

With that in mind, you have to set you environment in your job before calling the enviroments variables, just like this:

run-program:
  runs-on: ubuntu-latest
  needs: build

  environment: TEST # set environment
  env:              # and then... call your variables
    TESTEE: ${{ vars.TESTEE }}

  steps:
    - name: Check out repository code
      uses: actions/checkout@v4

    - name: Run main file
      run: python app/main.py

I hope this can help you, have a nice day! 😄

anthony9187 commented 11 months ago

Thanks @iuritorres for writing this up! I was able to resolve this in my repo using some of the information here. Adding environment kept giving me errors, but by adding

env:
  MY_VAR:

to the job in my workflow file, I was able to get the plugin to stop flagging uses of env.MY_VAR. Not sure if this is a hack, but it worked for me

edit: clarity

cjbland commented 11 months ago

Here are my steps to resolve the warningContext access might be invalid: TOKEN:

  1. Install the GitHub Actions extension in VS Code.
  2. Open the GitHub Actions tab and ensure that you are logged in and have fetched the action info for your Git repository.
  3. In the SETTINGS section, verify the presence of the variables you have set under "Environments" and "Secrets".
  4. If the warning persists, try running "Refresh current branch" from the Command Palette. Alternatively, you can restart VS Code.

image

This comment above in combination with running "Developer: Reload window" worked for me.

HebaruSan commented 11 months ago

In case someone else has the same problem, I used the remote name origin for my personal fork and upstream for the org fork (which has the secrets), so I had to update this setting:

image

davecaplinger commented 11 months ago

Unfortunately, even if the GitHub Actions extension is successfully logged in and Environments/Secrets/Variables are visible in the sidebar, I'm still having the issue. The lint warnings still appear if the variable is defined in a previous step via >> $GITHUB_ENV, such as in this example: image (I'm using version 0.26.2 if it matters)

LZhangCognite commented 10 months ago

Unfortunately, even if the GitHub Actions extension is successfully logged in and Environments/Secrets/Variables are visible in the sidebar, I'm still having the issue. The lint warnings still appear if the variable is defined in a previous step via >> $GITHUB_ENV, such as in this example: image (I'm using version 0.26.2 if it matters)

I have exactly the same issue as yours. Quite annoying. (version 0.26.2)

bartvdbraak commented 10 months ago

Is there a way to disable this warning in VSCode?

pogilvieCB commented 10 months ago

Uninstalling / Installing again seems to have worked for me (so far)

terozio commented 10 months ago

How should this work for callable workflows? The plugin obviously can't know if necessary secrets/vars are in place in the repository which invokes my callable workflow.

There should definitely be a enable/disable for this feature.

pwojATS commented 10 months ago

Thanks @iuritorres for writing this up! I was able to resolve this in my repo using some of the information here. Adding environment kept giving me errors, but by adding

env:
  MY_VAR:

to the job in my workflow file, I was able to get the plugin to stop flagging uses of env.MY_VAR. Not sure if this is a hack, but it worked for me

edit: clarity

This worked for me.

katelovescode commented 10 months ago

For me I had to log into Github in the GithubActions plugin, and Developer: Reload Window and then it worked.

gregops312 commented 10 months ago

As a side but important note, it does seem that the GItHub Actions extension does not handle the secret contexts when working in a multi-project workspace. That is the context for which I find this error occurring. When I open a single Git repository in a new window there are no errors.

And the GitHub Actions panel looks like:

Screenshot 2023-12-08 at 1 10 39 PM

The GitHub extension meanwhile handles this perfectly fine in multi-project workspaces.

If I ever get some free time, I'll try to look at the code or compare it to another extension to see what I can find, but I am definitely out of my depth.

jfaMan commented 9 months ago

Here are my steps to resolve the warningContext access might be invalid: TOKEN:

  1. Install the GitHub Actions extension in VS Code.
  2. Open the GitHub Actions tab and ensure that you are logged in and have fetched the action info for your Git repository.
  3. In the SETTINGS section, verify the presence of the variables you have set under "Environments" and "Secrets".
  4. If the warning persists, try running "Refresh current branch" from the Command Palette. Alternatively, you can restart VS Code.

image

This didn't work for me. My difference is I'm using environment secrets/variables, not repository. This also only happens for variables for me and not secrets.

This seems to only happen when environment property is dynamic.

image

Same issue. My environment is dynamic. v0.26.2