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

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

Open
Tracked by #275
afefer opened this issue Jun 21, 2023 · 96 comments
Open
Tracked by #275
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@afefer
Copy link

afefer commented Jun 21, 2023

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
Copy link

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
Copy link

moshest commented Jul 12, 2023

Any update on this?

@acharyasaagar
Copy link

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

@evertonspader-tomtom
Copy link

Seeing the same here constantly with v0.25.8

@avh03
Copy link

avh03 commented Jul 13, 2023

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

@anthony9187
Copy link

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

@mickael-h
Copy link

Same here. A bit annoying indeed 👍

@Bohemus307
Copy link

Still persists kind of embarrassing for GH

@enriquepevida
Copy link

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

@felipesu19 felipesu19 moved this from Backlog 🗒 to Triaged 📝 in GitHub Actions VS Code Extension Jul 26, 2023
@felipesu19
Copy link
Collaborator

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.

@felipesu19 felipesu19 added the help wanted Extra attention is needed label Jul 26, 2023
@PrimeTimeTran
Copy link

PrimeTimeTran commented Jul 29, 2023

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

@techguydave
Copy link

techguydave commented Aug 6, 2023

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
Copy link

japo32 commented Aug 7, 2023

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
Copy link

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
Copy link

larouxn commented Aug 16, 2023

👋 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
Copy link

gregalia commented Aug 17, 2023

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

v0.26.1

@JoelYoung01
Copy link

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

This worked for me.

Cyberboss added a commit to tgstation/tgstation-server that referenced this issue Aug 25, 2023
@BertelBB
Copy link

This seems to only happen when environment property is dynamic.

image

@marano
Copy link

marano commented Sep 1, 2023

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

Screenshot 2023-09-01 at 07 48 23

@budokans
Copy link

budokans commented Sep 5, 2023

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
Copy link

BertelBB commented Sep 5, 2023

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
Copy link

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
Copy link

qortex commented Sep 7, 2023

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.

@SaraGMatos
Copy link

Relogging into Actions and reloading window fixed the warning for me too!

@ezfe
Copy link

ezfe commented Apr 25, 2024

Joining the club asking about this - I've got dynamic environment variables and VS Code extension won't shut up about me referencing them

@fnfup
Copy link

fnfup commented May 8, 2024

I can also confirm this happens when you specify the jobs context environment property dynamically. It's not able to properly track that a variable exists. This is specific to "variables" my "secrets" seem to be tracked correctly.

@klausbadelt
Copy link

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.

We do have all variables "in our GitHub account", still getting VS Code warnings.

@klausbadelt
Copy link

klausbadelt commented May 14, 2024

@jivea

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.

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

Screenshot 2024-05-14 at 12 22 41 Screenshot 2024-05-14 at 12 23 35

@JoseEduardoCarrera
Copy link

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

@Hassen-Ahmed
Copy link

This worked for me after carefully adding GitHub Secrets, pushing/pulling my repo, and then pressing Ctrl + Shift + P and selecting "Developer: Reload Window.

@ssbarnea
Copy link

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.

@sunski411
Copy link

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.

@scarecrow-11
Copy link

Restarting the VSCode Window doesn't seem to be working here.

@8192K
Copy link

8192K commented Jun 25, 2024

In a devcontainer, the only way for me was to disable the extension, click reload and then enable it again.

@grantjoy
Copy link

grantjoy commented Jun 26, 2024

After signin in the Github Actions extensions, I also had to tick the "Use-enterprise" option in the Github Action extension settings. Repo belongs to an organization account. Hope this will help someone.

This did it for me. Thank you @jivea!

@brimmann
Copy link

Restarting worked for me.

@OkkarMin
Copy link

OkkarMin commented Aug 7, 2024

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.

This worked for me!

@grantjoy
Copy link

grantjoy commented Aug 7, 2024

Use-enterprise worked for a while until it stopped working. Downgrading to 0.25.7 got it working again.

Something changed between 0.25.7 and 0.25.8 that broke the auth for the extension and that bug persists today through all version after 0.25.7.

The error I see when moving from 0.25.7 and 0.25.8 (after authing in 0.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.

@boonyarit-iamsaard
Copy link

Here is my workaround, I switched from SSH to HTTPS and the warning disappeared. I hope this helps.

@ssbarnea
Copy link

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:

    outputs:
      matrix: ${{ steps.generate_matrix.outputs.matrix }} # noqa: unknown-context
      # triggers ^ "Context access might be invalid: matrix"

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

@grantjoy
Copy link

grantjoy commented Aug 14, 2024

@boonyarit-iamsaard thanks for the suggestion but I run into the same problem using HTTPS as I do for SSH auth.

@ssbarnea I don't understand why they are still upgrading it at this point, as recently as 2 months ago. They broke it in 0.25.8 and just keep releasing broken versions.

@Zoltag
Copy link

Zoltag commented Sep 12, 2024

Environment: WSL2 Ubuntu
Github Actions version: v0.26.5

I am using a mixed environment - Github Enterprise for our codebase and Github for external resources. When I select Use-Enterprise, external resources are shown to be unavailable and when I deselect this option, internal resources are unavailable

image
image

In the first screenshot, it shows invalid token warnings - A simple developer reload window + sign back into Github is enough to resolve these, but the Sonar action from github.com cannot be found

In the second screenshot, the secrets seem to be detected correctly (despite being in the Enterprise repo), but the action located in the enterprise git cannot be found (even though I am authenticated to both enterprise and public githubs, action resolution appears to be linked to the Use-Enterprise toggle, while secrets resolution seems to always work - albeit with some bugs)

@SantiiRepair
Copy link

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.

Not working

@rohityadav-sas
Copy link

@jivea

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.

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

Screenshot 2024-05-14 at 12 22 41 Screenshot 2024-05-14 at 12 23 35

This worked for me

@gekh
Copy link

gekh commented Sep 17, 2024

I have two actions for test and production branches. What helped me:

  • Git: Checkout to... test
  • Developer: Reload window
  • Git: Checkout to... produciton
  • Developer: Reload window

@tensor-works
Copy link

Still an issue almost 2 year later what is the github team doing

@Hecedu
Copy link

Hecedu commented Oct 17, 2024

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:

jobs:
  reusable_job:
    name: Reusable job for ${{inputs.environment}}
    runs-on: ubuntu-latest
    environment:
      name: ${{inputs.environment}}

This causes all references to environment variables to display the warning message, even if they have been properly defined in their respective environments.

@iann838
Copy link

iann838 commented Oct 28, 2024

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

@SteviePreston
Copy link

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

image

@krukonshedul
Copy link

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.

@mitsukuri
Copy link

Still an issue almost 2 year later what is the github team doing

Serving the board of directors who serve the investors who staked all their money on AI

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
Status: Triaged 📝
Development

No branches or pull requests