Fix errorRequest tests not testing the right thing#662
Merged
wolfy1339 merged 2 commits intooctokit:mainfrom Feb 19, 2026
Merged
Fix errorRequest tests not testing the right thing#662wolfy1339 merged 2 commits intooctokit:mainfrom
errorRequest tests not testing the right thing#662wolfy1339 merged 2 commits intooctokit:mainfrom
Conversation
|
👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with |
wolfy1339
reviewed
Feb 19, 2026
Member
wolfy1339
left a comment
There was a problem hiding this comment.
Some minor changes, otherwise it looks good.
Co-authored-by: wolfy1339 <4595477+wolfy1339@users.noreply.github.com>
wolfy1339
approved these changes
Feb 19, 2026
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.
The
"should override the state.retries property with the options.request.retries properties"test forerrorRequestcontains a bug. This becomes apparent if we start typing the test values. TheRequestErrorconstructor expects an argument of typeRequestErrorOptions, which is defined as:We call the constructor with
new RequestError("Internal server error", 500, errorOptions). TheerrorOptionsvalue is untyped and the inferred type happens to be compatible withRequestErrorOptions, but is subtly incorrect. If we type therequestobject, the error becomes apparent:The correct place for the
retries: 5property would actually be in the (nested)requestobject of typeRequestRequestOptions:This mistake leads to two follow-up issues.
The first is that
errorRequestis called witherrorOptionsas argument. In #661, I gave theoptionsparameter of theerrorRequestfunction a minimal type of{ request: RequestRequestOptions }. It so happens that both the erroneous and correct versions oferrorOptionsare compatible with this because they haverequestkeys, all properties inRequestRequestOptionsare optional by default, andRequestRequestOptionsallows arbitrary extra properties ofanytype.So, with the
retriesproperty in the wrong place anderrorRequestwilling to accept theRequestErrorOptionsvalue as argument,errorRequesthappens to do the right thing because it usesoptions.request.retriesto get the request-specificretriesvalue, but then constructs aRequestErrorresult based onerror(viaretryRequest):However, this is actually irrelevant, because the test asserts that:
So it is only really checking that
e(which is based onerror) contains the sameretriesvalue that's in the wrong place to begin with. If we added:It would fail because
e.request.retryAfterisundefined. Therefore, the test is actually only asserting that the thrownRequestErroris based onerror, and not thaterrorRequestactually choose theretriesvalue from therequestover the one in thestate. The correct assertion would beexpect(e.request.retries).toBe(5);.This PR fixes the construction of
errorOptionsin both this test and the other one forerrorRequest. It also fixes the assertions, and adds extra ones to avoid this problem.We could additionally change the type of
optionsto beRequired<EndpointDefaults>since that's what it would always get in practice, but this would then require us to construct a fullEndpointDefaultsobject in the tests. Happy to make this change if we think that is still needed on top of the test fixes.Before the change?
"should override the state.retries property with the options.request.retries properties"actually only asserts that the thrownRequestErroris based onerror, and not thaterrorRequestactually choose theretriesvalue from therequestover the one in thestate.After the change?
Pull request checklist
Does this introduce a breaking change?
Please see our docs on breaking changes to help!