Skip to content

Skip validation for dynamic environment #178

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

thezanke
Copy link

@thezanke thezanke commented May 5, 2025

fixes: github/vscode-github-actions#222

When the environment of a job is dynamically set the validator is unable to resolve the variables names it has access to; this PR should cause the context provider to skip validation of the variables when this is the case.

This is a an issue that has been around for a while and has been fixed for the "secrets" context provider (see github/vscode-github-actions#41) but was seemingly not addressed for the "variables" context provider. I have duplicated the change to the variables provider.

@Copilot Copilot AI review requested due to automatic review settings May 5, 2025 17:47
@thezanke thezanke requested a review from a team as a code owner May 5, 2025 17:47
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request addresses the inability of the variables context provider to correctly resolve variable names when a job's environment is set dynamically. The key changes include:

  • Introducing a new variables context (variablesContext) to handle dynamic environments.
  • Skipping validation by marking variablesContext.complete as false when the environment is dynamic or an expression.
  • Duplicating the fix previously applied to the secrets context provider.

@thezanke
Copy link
Author

thezanke commented May 5, 2025

Copilot is a little off... I didn't introduce a new variablesContext, I just moved the instantiation to be up above the block that determines the environment name.

@Niek
Copy link

Niek commented May 7, 2025

Great! This will solve the highest reacted issue in this repo.

@thezanke thezanke force-pushed the skip-dynamic-env-variable-validation branch from ea3b197 to 1ff96d2 Compare May 9, 2025 16:29
@thezanke thezanke requested a review from Copilot May 9, 2025 16:30
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes an issue in the variables context provider where the validator fails when handling dynamic environments, mirroring the fix previously applied to the secrets provider.

  • In variables.ts, adds logic to skip validation by setting the context’s completeness flag to false when encountering a dynamic environment.
  • In secrets.ts, corrects a typo in the inline comment regarding dynamic environments.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
languageserver/src/context-providers/variables.ts Added logic to bypass variable validation for dynamic environments.
languageserver/src/context-providers/secrets.ts Fixed a spelling error in the comment for dynamic environment handling.
Comments suppressed due to low confidence (1)

languageserver/src/context-providers/variables.ts:42

  • [nitpick] Consider extracting the logic for skipping validation on dynamic environments into a shared helper function, as similar behavior is implemented in the secrets context provider.
variablesContext.complete = false;

@thezanke thezanke force-pushed the skip-dynamic-env-variable-validation branch 2 times, most recently from fdb14e3 to e1a46e7 Compare May 9, 2025 16:40
@thezanke thezanke requested a review from Copilot May 9, 2025 16:41
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR skips variable validation for dynamically-set environments, mirroring the behavior already implemented for secrets. Key changes include:

  • Adding logic in the variables context provider to mark dynamic environments as incomplete.
  • Removing duplicate context initialization in variables.ts.
  • Fixing a spelling mistake in the secrets context provider.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
languageserver/src/context-providers/variables.ts Adds logic to skip variable validation for dynamic environments.
languageserver/src/context-providers/secrets.ts Corrects a spelling error in a comment regarding dynamic environments.

@thezanke thezanke force-pushed the skip-dynamic-env-variable-validation branch from e1a46e7 to 391a367 Compare May 9, 2025 16:53
@thezanke thezanke requested a review from Copilot May 12, 2025 20:20
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes the handling of dynamic environments for the variables context provider so that variable validation is skipped when the environment cannot be statically resolved.

  • Introduces a dynamic environment check in the variables context provider.
  • Mirrors existing dynamic environment handling implemented in the secrets provider, including a spelling correction in the comment.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
languageserver/src/context-providers/variables.ts Added a dynamic environment check that skips validation by setting the context as incomplete.
languageserver/src/context-providers/secrets.ts Fixed a comment typo regarding "environment".
Comments suppressed due to low confidence (1)

languageserver/src/context-providers/variables.ts:42

  • Ensure that marking the variablesContext as incomplete in both the non-string and missing environment cases is the intended design for dynamic environment handling and that it won't inadvertently skip validation for valid configurations.
variablesContext.complete = false;

@thezanke
Copy link
Author

Apologies for the copilot spam. I had thought the checks were saying it needed a happy copilot review before sending it to the codeowners, but I realize now I had misinterpreted them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

"Context access might be invalid" warning thrown for repository variables and secrets
2 participants