Skip to content

Commit

Permalink
Merge pull request #49350 from Expensify/neil-allowed-writes
Browse files Browse the repository at this point in the history
[No QA] Show too many writes error whenever it's set in response data
  • Loading branch information
iwiznia authored Sep 18, 2024
2 parents d13f37b + 2a7b995 commit be13f3f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/CONST.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,6 @@ const CONST = {
BAD_REQUEST: 400,
NOT_AUTHENTICATED: 407,
EXP_ERROR: 666,
MANY_WRITES_ERROR: 665,
UNABLE_TO_RETRY: 'unableToRetry',
UPDATE_REQUIRED: 426,
},
Expand Down
15 changes: 6 additions & 9 deletions src/libs/HttpUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,12 @@ function processHTTPRequest(url: string, method: RequestType = 'get', body: Form
});
}

if (response.jsonCode === CONST.JSON_CODE.MANY_WRITES_ERROR) {
if (response.data) {
const {phpCommandName, authWriteCommands} = response.data;
// eslint-disable-next-line max-len
const message = `The API call (${phpCommandName}) did more Auth write requests than allowed. Count ${authWriteCommands.length}, commands: ${authWriteCommands.join(
', ',
)}. Check the APIWriteCommands class in Web-Expensify`;
alert('Too many auth writes', message);
}
if (response.data && (response.data?.authWriteCommands?.length ?? 0)) {
const {phpCommandName, authWriteCommands} = response.data;
const message = `The API command ${phpCommandName} is doing too many Auth writes. Count ${authWriteCommands.length}, commands: ${authWriteCommands.join(
', ',
)}. If you modified this command, you MUST refactor it to remove the extra Auth writes. Otherwise, update the allowed write count in Web-Expensify APIWriteCommands.`;
alert('Too many auth writes', message);
}
if (response.jsonCode === CONST.JSON_CODE.UPDATE_REQUIRED) {
// Trigger a modal and disable the app as the user needs to upgrade to the latest minimum version to continue
Expand Down

0 comments on commit be13f3f

Please sign in to comment.