fix: add null check for regex match to prevent "Cannot read properties of undefined" error #6097
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.
Fixes #6096
Summary
This PR fixes the "Cannot read properties of undefined (reading '0')" error that occurs during retry attempts when handling 429 rate limit errors with Gemini API retry details.
Changes
match[1]
before accessing it inTask.ts
line 1835null
when the pattern doesn't match, which was causing the errorTesting
Technical Details
The issue occurred when the code tried to parse the retry delay from Gemini error details:
Now fixed to:
Important
Fixes a "Cannot read properties of undefined" error in
Task.ts
by adding a null check for regex matches, with tests for various retry scenarios.Task.ts
by adding a null check formatch[1]
in line 1835.null
due to non-matching patterns.Task.spec.ts
for 429 retry logic with Gemini error details.Task.ts
to include a null check formatch[1]
to prevent errors when accessing undefined properties.This description was created by
for f23b27a. You can customize this summary. It will automatically update as commits are pushed.