-
Notifications
You must be signed in to change notification settings - Fork 217
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
Revise API error codes #2293
Revise API error codes #2293
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.
Did you consider dropping 415 altogether?
@@ -2411,7 +2410,7 @@ instance Buildable e => LiftHandler (ErrSelectForPayment e) where | |||
, "transaction, then cancel the previous one first." | |||
] | |||
ErrSelectForPaymentTxTooLarge maxSize maxN -> | |||
apiError err400 TransactionIsTooBig $ mconcat | |||
apiError err403 TransactionIsTooBig $ mconcat |
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.
Not sure, I think this might actually be https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/413
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.
Sounds relevant for this use case indeed.
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.
Judging by the error message I'd say yes and no.
Yes, in case where the metadata is too big. As error message suggests:
Alternatively, try sending to less recipients or with smaller metadata.
Not necessarily, if the transaction turns out to be too big:
Note that I am selecting inputs randomly, so retrying *may work*
For the sake of keeping it simple I'd stay with 403
, which is more general.
@@ -2440,8 +2439,8 @@ instance LiftHandler ErrSignPayment where | |||
handler = \case | |||
ErrSignPaymentMkTx e -> handler e | |||
ErrSignPaymentNoSuchWallet e -> (handler e) | |||
{ errHTTPCode = 410 |
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.
Ok, so Gone
would be a viable option if we know the wallet existed beforehand. But I guess we don't?
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.
So, all uses of this type are as follows
withRootKey @_ @s ctx wid pwd ErrSignPaymentWithRootKey $ \xprv scheme -> do
let pwdP = preparePassphrase scheme pwd
mapExceptT atomically $ do
cp <- withExceptT ErrSignPaymentNoSuchWallet $ withNoSuchWallet wid $
readCheckpoint (PrimaryKey wid)
(cs', s') <- assignChangeAddressesForSelection
argGenChange cs (getState cp)
withExceptT ErrSignPaymentNoSuchWallet $
putCheckpoint (PrimaryKey wid) (updateState s' cp)
let keyFrom = isOwned (getState cp) (xprv, pwdP)
let rewardAcnt = mkRewardAccount (xprv, pwdP)
(tx, sealedTx) <- withExceptT ErrSignPaymentMkTx $ ExceptT $
pure $ mkStdTx tl rewardAcnt keyFrom txExp md cs'
(time, meta) <- liftIO $ mkTxMeta ti (currentTip cp) s' tx cs' txExp
return (tx, meta, time, sealedTx)
That means we can only hit this code-path if we found a root key for the given wallet id. Does that imply the wallet existed?
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.
Gone made sense in the context of concurrent request. When one creates a transaction, there are multiple back-and-forth with the database in separate db transactions. In principle, the wallet could disappear between any of these db transaction might there be a concurrent request deleting the wallet at the same time.
Arguably, this is veeeeeeeery edgy, and from a user perspective doesn't matter much. So changing to 404 sounds like a good move.
I haven't actually. As far as I see there are some tests against |
bors r+ |
bors r- |
Merge conflict. |
- 404 when wallet not found - 403 when transaction is too big
b84e830
to
6ba09a9
Compare
6ba09a9
to
3fe96b3
Compare
bors r+ |
Build succeeded: |
Issue Number
ADP-291
Overview
f533091
Revise error codes: - 404 when wallet not found - 403 when transaction is too big
430a31f
Update swagger
e90b264
Update integration tests
Comments
Whie reviewing #2258 I noticed that some error codes are a bit inconsistent, e.g.:
This pr is about to revise it and: