Don't treat Object.prototype keys as known backend error codes - #329
Open
Dusk1e wants to merge 1 commit into
Open
Don't treat Object.prototype keys as known backend error codes#329Dusk1e wants to merge 1 commit into
Dusk1e wants to merge 1 commit into
Conversation
isBackendApiErrorCode used `value in BACKEND_ERROR_CODE_TO_COFHE_ERROR_CODE`, and `in` also matches inherited keys. A backend `error` of toString, constructor, valueOf or hasOwnProperty was therefore treated as recognised, and mapApiErrorCodeToCofheErrorCode returned the inherited value, a function, instead of the fallback its docs promise. CofheError.code then held a non-string, so err.code === CofheErrorCode.X comparisons silently failed. The value comes straight from record.error in the response body, and the mapper runs in the decrypt and sealoutput error paths via submitRetry, tnDecryptV2 and tnSealOutputV2. Switched to an own-property check and added a case to the existing fallback tests. Recognised codes and ordinary unknown codes are unaffected.
🦋 Changeset detectedLatest commit: 3d5d9d3 The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@Dusk1e is attempting to deploy a commit to the Fhenix Team on Vercel. A member of the Team first needs to authorize it. |
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.
isBackendApiErrorCodechecksvalue in BACKEND_ERROR_CODE_TO_COFHE_ERROR_CODE, andinalso matches inherited keys. So a backenderroroftoString,constructor,valueOforhasOwnPropertycounts as recognised, andmapApiErrorCodeToCofheErrorCodereturns the inherited value, a function, instead of the fallback its own doc comment promises.CofheError.codethen holds a non-string, soerr.code === CofheErrorCode.Xquietly stops matching.The value is taken verbatim from
record.errorin the response body, and the mapper runs in the decrypt and sealoutput error paths throughsubmitRetry,tnDecryptV2andtnSealOutputV2, so it is reachable from whatever the endpoint returns.Switched to an own-property check. Added a case to the existing fallback tests in
apiError.test.ts; it fails on master withReceived [Function toString]and passes after. Full node suite is 377 passing, and the two failing files are the pre-existing@cofhe/test-setupresolution errors that also fail on master.tscreports the same three errors before and after, all from that same missing module.