-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add /v2/owners/:ownerAddress/safes
to gracefully handle errors
#2266
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. It's good that it still logs when it fails for a given chain.
I believe we should either return all of a user’s Safes or none at all. As a user, if some of my Safes are missing from a request, I would assume that all have been returned and the missing ones are lost. |
@PooyaRaki I think the proposed change is good for two reasons:
|
@katspaugh I agree with you, but I think we should inform users when we’re unable to fetch data from a specific chain due to ongoing issues. Imagine a power user with assets on three different chains—if they see assets on two chains but not the third, they’d likely be confused. If we give them a heads-up about the issue and suggest trying again later, that’s fine. Otherwise, it could be misleading and might hurt their trust in the platform. |
@PooyaRaki, I agree it's important to prioritise clarity for users. However, this approach aligns with the existing behaviour of endpoints that fetch data from every Transaction Service.
As we're fetching data from every chain, if a particular Transaction Service throws, we lack clarity as to whether the user has Safes on that chain, so it's potentially confusing either way. One alternative could be to return What are your thoughts? cc @katspaugh |
Yes, that’s what I was saying—we should display a warning indicating that Safes couldn’t be loaded there. Regarding returning |
An empty array indicates no Safes are owned on a given chain when a request is successful. This PR, however, excludes the chain in question if the request fails. I'd like to emphasise that returning
Let's see what @katspaugh thinks about this, as implementing such changes would require client updates, whereas this PR is intended as a quick fix. |
An empty array if no safes or |
I’d be happy to approve it, provided we ensure that our users are properly notified about the error. As an end user, I wouldn’t want to see my assets disappear simply because certain chains are experiencing issues. |
@ApiOkResponse({ | ||
schema: { | ||
type: 'object', | ||
additionalProperties: { | ||
type: 'array', | ||
items: { type: 'string' }, | ||
}, | ||
}, | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The types were previously incorrect.
This cannot be set in a class as the dynamic properties are top-level.
@@ -453,4 +457,327 @@ describe('Owners Controller (Unit)', () => { | |||
.expect({ statusCode: 502, message: 'Bad gateway' }); | |||
}); | |||
}); | |||
|
|||
describe('GET all safes by owner address', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from the graceful handling case, these duplicate the above for the v2 endpoint.
I've added a v2 endpoint implementing the above. Please lmk what you think, @PooyaRaki @katspaugh |
/v2/owners/:ownerAddress/safes
to gracefully handle errors
/v2/owners/:ownerAddress/safes
to gracefully handle errors/v2/chains/:chainId/owners/:ownerAddress/safes
to gracefully handle errors
/v2/chains/:chainId/owners/:ownerAddress/safes
to gracefully handle errors/v2/owners/:ownerAddress/safes
to gracefully handle errors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
}, | ||
}, | ||
}) | ||
@Get('/v2/owners/:ownerAddress/safes') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The v2 endpoint should be stored in another controller, ideally the folder structure would look like:
src/routes/owners/v1/owners.controller.ts
src/routes/owners/v2/owners.controller.ts
But for now, if you think restructuring the whole component is outside the scope of this PR we could just create a new v2 file in the same directory:
src/routes/owners/owners.controller.v1.ts
src/routes/owners/owners.controller.v2.ts
The ideal solution is the first option, but I’m also satisfied with the second.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per discussion, this was adjusted in 9121170:
There are now versioned controllers: OwnersControllerV1
and OwnersControllerV2
(owners.controller.v*
.ts). As the service/repository methods are controller agnostic, however, they retain the deprecated__
prefix, with JSDoc markers.
Do you think we should copy this behaviour to other endpoints that query all Transaction Services? |
Summary
When getting all Safes by owner (
/v1/owners/:ownerAddress/safes
), every Transaction Service is called. Should one or more throw, the request will as well.This adds a new endpoint (
/v2/owners/:ownerAddress/safes
) which returnsnull
for every chain which the Transaction Service threw for.Changes
Promise.allSettled
.