Skip to content
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

update 4xx responses in API spec #252

Merged
merged 1 commit into from
May 10, 2019
Merged

Conversation

piotr-iohk
Copy link
Contributor

Issue Number

Overview

  • I have updated 4xx responses in API spec

Comments

@@ -681,15 +682,13 @@ responsesPostWallet: &responsesPostWallet
schema: *ApiWallet

responsesGetWallet: &responsesGetWallet
<<: *responsesErr400
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no sure about this but I was not able to produce 400 for this

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if you send an invalid wallet id ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is not valid/existing wallet's id - it is always 404...
e.g. some wallet ids I'm testing -> https://github.com/input-output-hk/cardano-wallet/pull/251/files#diff-907b72a217c31fa13b9144cb7ba43cf3R834

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm... I'd expect the API to return a 400 for a illed-wallet id 🤔 ..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, so, because this is a path parameter, Servant actually ignores the route if it can't parse it and tries the next one that would match. Since there's none, it throws a 404. Hence not getting a 400. Not a big fan of this behavior to be honest, I don't think it's the most user-friendly but well.. I'll see if we have maybe a setting we can set to change that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is kind of inconsistent with what CLI returns:

$ stack exec -- cardano-wallet wallet get 617963656a409b8a6828dc3a09001de22af9040
wallet id should be an hex-encoded string of 40 characters

$ stack exec -- cardano-wallet wallet get 617963656a409b8a6828dc3a09001de22af90401
Wallet not found.

404 is okey(ish) from my perspective though (in the end it is Not Found whether id is valid or not ;)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, I've found this -> haskell-servant/servant#1155
A PR was made on the 27th of March, so it's rather new and not-yet-included in the last servant's release (made last feb). So, I'd rather stick that to the blackboard and consider improving the API once servant 0.17 is available!

In the meantime, we can remove the 400 from the API specification.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<<: *responsesErr404
<<: *responsesErr406
200:
description: Ok
schema: *ApiWallet

responsesDeleteWallet: &responsesDeleteWallet
<<: *responsesErr400
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

<<: *responsesErr404
<<: *responsesErr406
200:
description: Ok
schema: *ApiWallet

responsesDeleteWallet: &responsesDeleteWallet
<<: *responsesErr400
<<: *responsesErr404
<<: *responsesErr406
<<: *responsesErr423
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also don't know how to produce 423...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we would be more granular in the wallet error reporting but we are not there yet. I think for now, it'll just hang and wait for the resource to become available again.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shall we remove it then?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oui.

@piotr-iohk piotr-iohk merged commit b250e6a into master May 10, 2019
@piotr-iohk piotr-iohk deleted the piotr/220/update_api_spec branch May 10, 2019 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants