-
Notifications
You must be signed in to change notification settings - Fork 53
fix: suppress false warnings "Context access might be invalid" for secrets/vars #223
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
base: main
Are you sure you want to change the base?
fix: suppress false warnings "Context access might be invalid" for secrets/vars #223
Conversation
When GitHub API client or repository context is not available, mark secrets and vars contexts as incomplete instead of returning undefined. This prevents false 'Context access might be invalid' warnings for repository secrets and variables. Fixes github/vscode-github-actions#222
…riables-and-secrets
There was a problem hiding this 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 fixes false "Context access might be invalid" warnings for secrets and variables by introducing a configurable validation mode that properly handles cases where the GitHub client or repository context is temporarily unavailable during language server initialization.
Key changes:
- Added
SecretsValidationModetype with three options: "auto" (default), "always", and "never" - Modified context providers to return incomplete context instead of undefined when validation should be suppressed
- Added comprehensive test coverage for the new validation modes
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
languageserver/src/initializationOptions.ts |
Defines the new SecretsValidationMode type and adds the secretsValidation configuration option to InitializationOptions |
languageserver/src/context-providers.ts |
Implements the validation mode logic to suppress or enable warnings based on configuration and client/repo availability |
languageserver/src/context-providers.test.ts |
Adds test suite covering all three validation modes for secrets and variables context |
languageserver/src/connection.ts |
Reads and propagates the secretsValidation setting from initialization options to context provider calls |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
languageserver/src/context-providers.ts:62
- [nitpick] The switch statement doesn't have a default case and implicitly returns
undefinedfor unknown context names. Consider adding an explicitdefaultcase for clarity:
switch (name) {
case "secrets":
return await getSecrets(workflowContext, client, cache, repo, defaultContext, mode);
case "vars":
return await getVariables(workflowContext, client, cache, repo, defaultContext);
case "steps":
return await getStepsContext(client, cache, defaultContext, workflowContext);
default:
return undefined;
}This makes the intended behavior more explicit and easier to understand.
switch (name) {
case "secrets":
return await getSecrets(workflowContext, client, cache, repo, defaultContext, mode);
case "vars":
return await getVariables(workflowContext, client, cache, repo, defaultContext);
case "steps":
return await getStepsContext(client, cache, defaultContext, workflowContext);
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Users experience false "Context access might be invalid" warnings for repository secrets and variables because of temporarily unavailable context during language server initialization.
contextProvidersreturnsundefined, causing validation to use an emptyDescriptionDictionarywithcomplete = true, which flags all secret/variable access as invalid.Fixes github/vscode-github-actions#222
Required for PR 534 /github/vscode-github-actions
This pull request introduces a configurable mechanism for controlling the validation of secrets and variables context in the language server:
SecretsValidationModetype ("auto" | "always" | "never") and an optionalsecretsValidationfield to theInitializationOptionsinterface ininitializationOptions.ts. This allows users to configure how secrets and variables validation is handled.connection.tsto read and propagate thesecretsValidationoption throughout the initialization and context provider configuration, ensuring the chosen mode is respected during server operation.contextProvidersincontext-providers.tsto handle secrets/variables context differently based on the selected validation mode. In"never"and"auto"modes,incompletecontext is returned to suppress warnings if the client or repo is missing; in"always"mode,undefinedis returned to trigger warnings.contextProvidersincontext-providers.test.ts, covering all secrets validation modes and ensuring correct context behavior for secrets and variables.Unfixed problem:

Fixed:
