vscode-github-actions: "Context access might be invalid" warning thrown for repository variables and secrets
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
Extension Version
v0.25.8
Additional context Add any other context about the problem here.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 359
- Comments: 137 (1 by maintainers)
Commits related to this issue
- Workaround for https://github.com/github/vscode-github-actions/issues/222 — committed to tgstation/tgstation-server by Cyberboss 3 years ago
- ci: declare DEFAULT_PLATFORM env stops some warnings in VS Code https://github.com/github/vscode-github-actions/issues/222#issuecomment-1765301497 — committed to Agoric/agoric-3-proposals by turadg 3 years 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 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.
Hello everyone,
After signin in the Github Actions extensions, I alos had to tick the “Use-enterprise” option in the Github Action extension settings. Repo belongs to an organization account. Hope this will help someone.
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.
+1 on this comment and issue
Here are my steps to resolve the warning
Context access might be invalid: TOKEN:This was fixed for me by opening the GitHub actions side panel, making sure its logged in, refreshing, then opening the Secrets dropdown. Then after that, I ran the vscode command > Developer: Reload Window.
Now it is working fine.
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.Please, I beg you, let us silence these. Every time my problems counter in VSCode creeps above 1, a tiny piece of my soul withers. I strive for a world where my commits bring joy, not chaos—yet this extension haunts me like an unshushable poltergeist. Help me break free from this cycle of despair! 😭🙏
Still an issue almost 2 year later what is the github team doing
This worked for me.
Can people please stop adding
+1to this issue? Yes, it’s annoying that this is not fixed. But spamming the issue does not help anyone, in particular because it’s probably subscribed by hundreds if not thousands of people who get notified just because someone encountered this issue as well.If you cannot live with the issue, uninstall the plugin or fix it yourself. Otherwise, wait, but do that in silence, please. Thank you.
Serving the board of directors who serve the investors who staked all their money on AI
This seems to only happen when
environmentproperty is dynamic.This still happens with all dynamically generated environment variables and is pretty annoying
I tried this but it came back 😦
This should really be something that can be disabled in the extension settings
👋 Reporting in, still happening on
v0.26.1.Agreed, there should at least be a
# github-actions-extension ignorecomment one can use.How on earth is this an issue almost 3 years later. This is still not fixed.
I get this warning for any environment variable exported in a previous step via
echo "foo=bar" >>$GITHUB_ENVv0.26.1
Just wanted to confirm that the issue continues to persist in 0.25.8 (and it’s feeling really annoying)
This comment above in combination with running “Developer: Reload window” worked for me.
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
(I’m using version
>> $GITHUB_ENV, such as in this example:0.26.2if it matters)Still persists kind of embarrassing for GH
I had to sign in via the side using the GitHub Actions extension and do a full reload. If you are on an enterprise repo, Enable Github-actions: Use-enterprise
This is completely unable to handle dynamic output parameters, such as the ones from
aws-actions/amazon-ecr-login@v2. I’d be grateful for an ability to completely turn this particular validation off. It degrades my experience significantly more than it does provide any value.@jivea
That just logs me out, without being able to log back in (“Sign in” button no longer works). I guess that’s why you don’t see the warnings - you’re logged out. I suspect that’s because now the Github-enterprise Uri is missing. (We do run a GitHub organization, but not GitHub enterprise).
Joining the club asking about this - I’ve got dynamic environment variables and VS Code extension won’t shut up about me referencing them
Please prioritize fixing this or allowing for silencing warnings. It’s quite annoying.
Easiest fix for this is uninstalling the extension
Thanks @iuritorres for writing this up! I was able to resolve this in my repo using some of the information here. Adding
environmentkept giving me errors, but by addingto the
jobin my workflow file, I was able to get the plugin to stop flagging uses ofenv.MY_VAR. Not sure if this is a hack, but it worked for meedit: clarity
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.
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.
Like many before, I happened upon this issue of woe within minutes of installing this extension. I even spent 5 minutes trying to figure out how I might contemplate sending a PR. I have not been able to figure out where this finding even comes from, searching in earnest. I guess I too shall have to just uninstall it, which makes me sad.
Jesus Christ, 5 minutes into using extension and already a 2 year old bug. Justifies it’s 3 star rating.
Would be great to either be able to inline suppress warning, or perhaps allow to set a default value for when the secret is not present, or disable warnings altogether. I use the extension only for intellisense, don’t intend to ever log into GitHub in VSCode.
If you installed the GitHub Actions extension, all you have to do is perform a Developer reload in VS code ‘Developer: Reload Window’ and the error should go away.
This did it for me. Thank you @jivea!
Persisteted in version
0.27.1but is there any config or anything we could do to ignore this warning?I have exactly the same issue as yours. Quite annoying. (version 0.26.2)
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.wtf
Persisted in version
0.27.1.When are we getting a suppression setting, seeing this sight every single time while contributing to open source for the past several years has been to the point of irritation.
I have found a solution that works at least for me. SECRET squiggles and ENVIRONMENT squiggles have had different causes (in my case at least).
env:statement with definition of each Environment variable I was about to use in particular Step. Example:This Step definition causes warning squiggles to appear under
env.TAG_VERSION(BAD):How this warning looks like in IDE:
Now, this Step definition REMOVES warning squiggles under
env.TAG_VERSION(GOOD):How this looks like now:
How my Environment variables are defined (in previous prior to
Build x86 ImageStep ):There is no other place in whole repository where I would somehow mention to use this Environment variable; the mentioned definitions were enough for me.
Although my workflow was working well even without adding this
env:property, adding it have resolved my issue with warning squiggles.ah, i see this is an actual issue. i was going mad with this. Let´s hope it´s fixed soon.
also seeing this constantly in
v0.25.8withenvvariables, but notsecretsWe should absolutely be able to silence these false positive warnings.
In our case, we have a Production environment that contains some secrets that are erroneously detected by this VSCode extension as missing.
Can the creators/contributors provide an update here, please? When will we be able to silence the warnings?
@cschleiden, @joshmgross, @thyeggman, @felipesu19
Is there any way to disable this warning when using a dynamic environment?
You need to understand how this works. it fetches variables name from your GitHub account if you have created a variable there it will not give any warning.
Giving a Warning due to
PHPSESSIDis not in my Github secrets.If the warning persists even after adding the variable in GitHub, consider reloading VS Code.
Would be great if this could work without requiring github login. I would be completely fine with it assuming the required secrets exist when it doesn’t know otherwise.
+1 @TimDiekmann
The problem seem to still be there (VSCode, MacOS, everything latest update - for
secretsat least). Especially forsecretsit would be better to not try to check them locally.Not working
Restarting the VSCode Window doesn’t seem to be working here.
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)
With that in mind, you have to set you environment in your job before calling the enviroments variables, just like this:
I hope this can help you, have a nice day! 😄
Same here. Restarting VS Code after install and login fixed the issue for me!
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.
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.
Same here. A bit annoying indeed 👍
I still see this as well; the extension version is v0.25.8
Any update on this?
Use-enterprise doesn’t work for me. And I don’t even understand the warning. Uninstalled.
Hey @hongkongkiwi! Great question. This workaround works with normal GitHub accounts too - you don’t need an Enterprise account.
The
"github-actions.use-enterprise": truesetting is meant for self-hosted GitHub Enterprise Server instances, not for GitHub Enterprise plans on github.com. Since most of us (myself included, even with Enterprise) use github.com rather than running our own GitHub server, this setting essentially tricks the extension into skipping the problematic validation.So yes, it should work perfectly fine for you regardless of your GitHub plan type! The key is that we’re not actually using a self-hosted Enterprise Server - we’re just leveraging how the extension behaves when it thinks we are. 😊
Does this fix actually require an Enterprise Github account? or does it work with normal accounts too?
@felipesu19 would you still review a PR? the least i can do is contribute a
don't verify context accesssetting so that people can get rid of the warnings. should be tiny simple PR.who knows, i may spot the actual issue.
edit: did some research, ignoring the warning here is not trivial. this extension only hooks up the actual language server and passes stuff. happy to extend my offer to also build in support in the language server to turn off this check. then all that is left here is adding the option for the user to set which i finished already. this could be improved quick if maintainers want to, lmk.
This worked for me after carefully adding GitHub Secrets, pushing/pulling my repo, and then pressing Ctrl + Shift + P and selecting "Developer: Reload Window.
For me I had to log into Github in the GithubActions plugin, and Developer: Reload Window and then it worked.
I am really annoyed by this - sorry
Don’t worry guys, the Copilot will fix this in two weeQs!
While I can fully understand why this feature was implemented there is a significant number of power-users of GHA which might use advances workflows, where the static analysis fails.
I have another job that is producing the entire matrix for for running the matrix tests jobs, and I am using its output. Here is how is used:
The only way to avoid is is to have some kind of magic noqa comments to silence it, like the comment that I added in the snippet.
Looking at https://github.com/github/vscode-github-actions/graphs/contributors I realise that this extension is not really under any kinda of active maintenance. In fact the last change that worth being mentioned in the release notes was in may 2023 😃
Still, I hope that @thyeggman might find some time to help here, even it would be with a comment that just suggests how this could be addressed (code reference, prefered way to deal with it in code).
This is my experience:
After opened .yml file for the first time, VS Code Askme to install the Github Action Extension, i get access to my secrets and variables in the lateral panel but in config i get the same warn message, but i restarted the VS Code Programm and the warn message dissapeared
This worked for me.
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.
In case someone else has the same problem, I used the remote name
originfor my personal fork andupstreamfor the org fork (which has the secrets), so I had to update this setting:I’m seeing this on
${{ env.STORE_PATH }}Yeah, this worked for me, thanks for sharing.
I’m using Github Actions v0.26.2.
Open the “github actions” extension side-panel and click “Sign in with Github”.
Authenticating this extension with Github worked for me.
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.
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.I found that toggling the “Use-enterprise” setting mentioned above, first on then off again, was enough to remove the warnings.
In my case it is solved by installing github action and restart editor !!
I want to use the language server for GHA without having the sidebar enabled but apparently that is required in order to access the secrets.
I would rather have an option to disable messages like this as they are distracting and incorrect. They should appear only when the extension can access secrets and fails to find them, not when it does not have access to them.
Relogging into Actions and reloading window fixed the warning for me too!
If you’re still experiencing this issue, try using a
fromJSON(toJSON(env | vars | secrets).[...]An example of how it’d look:
This method’s not the best of solutions, though it works if your local repository is unable to fetch / verify whether the specified environment variable or secret is really present.
I still wouldn’t rely on this, rather go for this method of trying to resolve it, as it worked for my latest repository.
Didn’t saw it mentioned, so… dumb workaround if anyone needs:
Easy to restore proper syntax when/if fix comes.
Seeing the same here constantly with
v0.25.8wtf indeed… sad, really.
1 and half a year passed and still nothing lmao
this is really annoying
@hongkongkiwi Is open-source, feel free to open a pull request and complain if it gets ignored!
This issue is also triggered by using a supported feature in which one passes an environment variable as the environment name for a reusable job eg:
This causes all references to environment variables to display the warning message, even if they have been properly defined in their respective environments.
This worked for me
Use-enterprise worked for a while until it stopped working. Downgrading to
0.25.7got it working again.Something changed between
0.25.7and0.25.8that broke the auth for the extension and that bug persists today through all version after0.25.7.The error I see when moving from
0.25.7and0.25.8(after authing in0.25.7) is:Error running command github-actions.explorer.current-branch.refresh: command 'github-actions.explorer.current-branch.refresh' not found. This is likely caused by the extension that contributes github-actions.explorer.current-branch.refresh.In a devcontainer, the only way for me was to disable the extension, click reload and then enable it again.
For me, it seems to be working out of the box now, without having to apply any of the proposed fixes from here
@maksims-terjohins - thanks, this solved the problem for me too.
If you’re facing the “Context access might be invalid” warning for repository variables and secrets. The reason is our YAML file does not have access to production environment variables when we’re adding it. The warning is simple and here is what worked for me.
This should make the warning disappear.
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. 😃
Saw this error after installing and signing in. Uninstalled it and reinstalled it, and it worked fine after
I uninstalled, reinstalled and restarted VSCode and then the warnings went away.
v0.25.8