fix: guard against undefined testFiles when findTests throws - #3473
Open
tsushanth wants to merge 1 commit into
Open
fix: guard against undefined testFiles when findTests throws#3473tsushanth wants to merge 1 commit into
tsushanth wants to merge 1 commit into
Conversation
When globs.findTests rejects (e.g. bad file patterns or IO errors), the catch block sets setupOrGlobError but leaves testFiles undefined. The subsequent selectionInsights object accesses testFiles.length, which crashes with a TypeError before setupOrGlobError can be re-thrown. Use optional chaining so a glob failure is surfaced via the existing setupOrGlobError path rather than crashing unexpectedly.
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.
What
When
globs.findTestsrejects (bad glob config, permission error, IO failure), thecatchblock inApi#runstores the error insetupOrGlobErrorbut leavestestFilesasundefined. The very next statement buildsselectionInsights:This crashes before
setupOrGlobErroris ever re-thrown, so the original error is swallowed and the user sees a confusingTypeErrorinstead.Fix
Use optional chaining so the property access is safe when
testFilesis undefined:Reproduction
Configure
avawith afilesglob that causesfindTeststo throw (e.g., pass an invalid pattern that triggers the internal validation error), or simulate an IO failure inglobs.findTests. The run crashes with:instead of surfacing the underlying glob/config error.