Title: Workflow expression variable reference checks miss some variables · Issue #61 · github/vscode-github-actions · GitHub
Open Graph Title: Workflow expression variable reference checks miss some variables · Issue #61 · github/vscode-github-actions
X Title: Workflow expression variable reference checks miss some variables · Issue #61 · github/vscode-github-actions
Description: Describe the bug The expression checker looks to see if variables that are referenced are actually defined and warns if a context reference may not be valid. This can cause bugs like #47 , but also it's missing some variables completely....
Open Graph Description: Describe the bug The expression checker looks to see if variables that are referenced are actually defined and warns if a context reference may not be valid. This can cause bugs like #47 , but also...
X Description: Describe the bug The expression checker looks to see if variables that are referenced are actually defined and warns if a context reference may not be valid. This can cause bugs like #47 , but also...
Opengraph URL: https://github.com/github/vscode-github-actions/issues/61
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Workflow expression variable reference checks miss some variables","articleBody":"**Describe the bug**\r\nThe expression checker looks to see if variables that are referenced are actually defined and warns if a context reference may not be valid. This can cause bugs like #47 , but also it's missing some variables completely.\r\n\r\nFrom the above issue:\r\n\r\n```yaml\r\nname: \"Context access might be invalid\"\r\non: push\r\njobs:\r\n context-access-might-be-invalid:\r\n runs-on: ubuntu-latest\r\n steps:\r\n - name: Checkout\r\n uses: actions/checkout@v3\r\n\r\n - name: Setup environment variables\r\n uses: rlespinasse/github-slug-action@v4\r\n\r\n - name: Print custom environment variables\r\n run: echo ${{ env.GITHUB_REF_SLUG }}\r\n```\r\n\r\nThis raises the `Context access might be invalid` warning for `env.GITHUB_REF_SLUG`.\r\n\r\nIf the expression itself branches like so, only the ~\"false\"~ path as evaluated in the extension will raise a warning:\r\n\r\n```yaml\r\nname: \"Context access might be invalid\"\r\non: push\r\njobs:\r\n context-access-might-be-invalid:\r\n runs-on: ubuntu-latest\r\n steps:\r\n - name: Checkout\r\n uses: actions/checkout@v3\r\n\r\n - name: Setup environment variables\r\n uses: rlespinasse/github-slug-action@v4\r\n\r\n - name: Print custom environment variables\r\n run: echo ${{ true == false && env.FAKE_VAR || env.GITHUB_REF_SLUG }}\r\n```\r\n\r\nHere, the warning will be raised again, but only for `env.GITHUB_REF_SLUG`.\r\n\r\nIf we \"define\" the env var in an `env` block explicitly:\r\n\r\n```yaml\r\nname: \"Context access might be invalid\"\r\non: push\r\njobs:\r\n context-access-might-be-invalid:\r\n runs-on: ubuntu-latest\r\n steps:\r\n - name: Checkout\r\n uses: actions/checkout@v3\r\n\r\n - name: Setup environment variables\r\n uses: rlespinasse/github-slug-action@v4\r\n\r\n - name: Print custom environment variables\r\n env:\r\n GITHUB_REF_SLUG: whatever\r\n run: echo ${{ true == false && env.FAKE_VAR || env.GITHUB_REF_SLUG }}\r\n```\r\n\r\nthen the warning goes away completely, and `env.FAKE_VAR` is never considered.\r\n\r\nAlternatively, if we change the expression to something that can be evaluated as `true` at parse time:\r\n\r\n```yaml\r\nname: \"Context access might be invalid\"\r\non: push\r\njobs:\r\n context-access-might-be-invalid:\r\n runs-on: ubuntu-latest\r\n steps:\r\n - name: Checkout\r\n uses: actions/checkout@v3\r\n\r\n - name: Setup environment variables\r\n uses: rlespinasse/github-slug-action@v4\r\n\r\n - name: Print custom environment variables\r\n run: echo ${{ true && env.FAKE_VAR || env.GITHUB_REF_SLUG }}\r\n```\r\n\r\nThen the warning will change to `env.FAKE_VAR` only, ignoring the other one.\r\n\r\n\r\n**To Reproduce**\r\nSee above.\r\n\r\n**Expected behavior**\r\nBoth vars are warned against.\r\n\r\n**Extension Version**\r\n`v0.25.3`\r\n","author":{"url":"https://github.com/briantist","@type":"Person","name":"briantist"},"datePublished":"2023-03-29T13:22:54Z","url":"https://github.com/github/vscode-github-actions/issues/61"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b5c0ea5d-3b4a-ada5-e76c-69c6e9c1108e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | DFA8:35C83D:458E24:64A601:6AFD839F |
| html-safe-nonce | 19340eb2b87fb8466a9e48f0bec87a7ea708a367c7b6fe52ac5590bba533925c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJERkE4OjM1QzgzRDo0NThFMjQ6NjRBNjAxOjZBRkQ4MzlGIiwidmlzaXRvcl9pZCI6Ijg0NjQ4NDQ3MTkyNzEwMTk0MjMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 19d5fc4f5a007e8e4c11869fdf0ca5bd3af33536b0362449f0137326918757cb |
| hovercard-subject-tag | issue:1645808352 |
| github-keyboard-shortcuts | repository,issues,actions,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/github/vscode-github-actions/61/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1d95e548e341e916e5bc0af7bdee3553d7e52dac040d5aaa107d26067ebf783e/github/vscode-github-actions/issues/61 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1d95e548e341e916e5bc0af7bdee3553d7e52dac040d5aaa107d26067ebf783e/github/vscode-github-actions/issues/61 |
| og:image:alt | Describe the bug The expression checker looks to see if variables that are referenced are actually defined and warns if a context reference may not be valid. This can cause bugs like #47 , but also... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | briantist |
| hostname | github.com |
| expected-hostname | github.com |
| None | 42d4967e3c8afca51ccac31f419a705af777226a95f025ea73387d87a306b326 |
| turbo-cache-control | no-preview |
| go-import | github.com/github/vscode-github-actions git https://github.com/github/vscode-github-actions.git |
| octolytics-dimension-user_id | 9919 |
| octolytics-dimension-user_login | github |
| octolytics-dimension-repository_id | 616663763 |
| octolytics-dimension-repository_nwo | github/vscode-github-actions |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 616663763 |
| octolytics-dimension-repository_network_root_nwo | github/vscode-github-actions |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 2329ceed0bc2c7b7c3b9f5f2db6abfc7b6fc3a50 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width