Update API.md to reflect microtime keyed errors#10145
Conversation
|
I'm actually curious how we want to handle the "other additional properties" case - should those also be keyed under the microtime? |
PauloGasparSv
left a comment
There was a problem hiding this comment.
LGTM
Just couldn't find Onyx::getErrorMicroTime on main.
@yuwenmemon feel free to merge, not merging so people can have time to look and discuss your last comment.
MariaHCD
left a comment
There was a problem hiding this comment.
I'm actually curious how we want to handle the "other additional properties" case - should those also be keyed under the microtime?
I'm thinking it makes sense to associate the additional properties with the same microtime key. For instance, in UpdatePersonalDetailsForWallet the API might return an additional prop 'errorCode' => 'ssnError' and later we might also return a different errorCode kbaNeeded.
If we didn't have the additional properties keyed under microtime the onyxData would look like:
[
[
'onyxMethod' => Onyx::METHOD_MERGE,
'key' => OnyxKeys::WALLET_ADDITIONAL_DETAILS,
'value' => [
'errors' => [
microtime() => 'We\'re having trouble verifying your SSN. Please enter the full 9 digits of your SSN.',
microtime() => 'We need to ask you a few more questions to finish validating your identity',
],
'errorCode' => self:: WALLET_ERROR_KBA, // This will indicate to the frontend that the user must be redirected to the AnswerQuestionsForWallet step
'idNumber' => $idNumber,
'questions' => $questions,
],
],
];The errorCode would be overwritten by the second error and while this wouldn't matter too much for this command since it's pattern C but if it were pattern B, we wouldn't want that prop to be overwritten, correct?
So perhaps it would be better if the onyxData looked like:
[
[
'onyxMethod' => Onyx::METHOD_MERGE,
'key' => OnyxKeys::WALLET_ADDITIONAL_DETAILS,
'value' => [
'errors' => [
microtime() => [
'error' => 'We\'re having trouble verifying your SSN. Please enter the full 9 digits of your SSN.',
'errorCode' => 'ssnError', // We'll use this code on the frontend to alter the ssn field to accept the full 9 digit ssn
]
microtime() => [
'error' => 'We need to ask you a few more questions to finish validating your identity',
'errorCode' => self:: WALLET_ERROR_KBA, // This will indicate to the frontend that the user must be redirected to the AnswerQuestionsForWallet step
'idNumber' => $idNumber,
'questions' => $questions,
]
],
],
],
];Thoughts?
| When there is an error on a WRITE response (`jsonCode!==200`), the error must come back to the client on the HTTPS response. The error is only relevant to the client that made the request and it wouldn't make sense to send it out to all connected clients. | ||
|
|
||
| Error messages should be returned and stored as a String under the `error` property. If absolutely needed, additional error properties can be stored under other, more specific fields that sit at the same level as `error`: | ||
| Error messages should be returned and stored as an object under the `errors` property, keyed by a [microtime](https://www.php.net/manual/en/function.microtime.php). If absolutely needed, additional error properties can be stored under other, more specific fields that sit at the same level as `errors`: |
There was a problem hiding this comment.
keyed by a microtime
I think you should mention that it is an int, and update it to use Onyx::getErrorMicroTime() instead. We can wait until that PR is merged.
Waiting for this thread's discussion https://expensify.slack.com/archives/C02HWMSMZEC/p1658356668529449 for an agreement on how to deal with multiple error messages
1d709b4
|
@neil-marcellini updated for your suggestion! |
neil-marcellini
left a comment
There was a problem hiding this comment.
Looks good, thanks 😄
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by @yuwenmemon in version: 1.1.87-0 🚀
|
|
🚀 Deployed to production by @yuwenmemon in version: 1.1.87-9 🚀
|
@iwiznia @bondydaa @neil-marcellini @Gonals @chiragsalian @MariaHCD please review
Update the API.md docs to reflect the fact that we want errors returned in an array keyed by the microtime.