Repository navigation
Conversation
Collaborator
|
Thanks @zunixport. This repo is a read-only mirror, so we've recreated the fix in our internal monorepo with you credited as co-author. It ships in the upcoming @opensea/sdk 12.11.1. On impact: the only first-party caller is Closing this PR since the change now lives in the monorepo. Thanks! |
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.
hasErrorCodethrows onnull/undefinedhasErrorCodeis a type guard declared overunknown:unknownincludesnullandundefined, but the implementation casts the argument and reads.codeoff it immediately. On a nullish value that throwsTypeError: Cannot read properties of null (reading 'code')— the guard crashes on exactly the inputs it exists to handle.Why it matters
Both values reach a
catch (error)binding in ordinary code:throw null, orPromise.reject()with no reason.hasErrorCodeis used that way inFulfillmentManager.isOrderFulfillable:The intent there is "inspect the code, otherwise rethrow as-is". For a nullish throw, the guard itself throws, so the caller receives an unrelated
TypeErrorthat says nothing about what actually failed, and thethrow errorfallback is skipped. The helper is also exported from the package root, so any consumer calling it according to its(error: unknown)signature hits the same crash.Fix
Return
falsefornull/undefinedbefore reading the property. Truthiness ofcodeis unchanged for every other input.Tests
Extended
test/sdk/misc.spec.ts(already covers other exports ofsrc/utils/utils.ts) with ahasErrorCodeblock:truefor an error carrying a code,falsefor a codeless one, and an explicit "does not throw" assertion fornull/undefined.