GoodDollar / GoodServer

Backend to support the GoodDAPP
MIT License
13 stars 12 forks source link

Frequent 412 "contact not found" OnGage error #398

Closed johnsmith-gooddollar closed 1 year ago

johnsmith-gooddollar commented 1 year ago
Alert Fired! Exception on Heroku/Syslog drain
1860 <190>1 2023-01-08T16:26:24.298708+00:00 app web.1 - - [33m2023-01-08T16:26:24.298Z - workerId:1 - warn (FROM: /user/claim userId: ): {"uuid":"g6BftjjcM7","message":"OnGage error:","context":["Request failed with status code 412",{"message":"Request failed with status code 412","stack":"Error: Request failed with status code 412\n    at createError (/app/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/app/node_modules/axios/lib/core/settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (/app/node_modules/axios/lib/adapters/http.js:293:11)\n    at IncomingMessage.emit (node:events:525:35)\n    at IncomingMessage.emit (node:domain:489:12)\n    at endReadableNT (node:internal/streams/readable:1358:12)\n    at processTicksAndRejections (node:internal/process/task_queues:83:21)","config":{"transitional":{"silentJSONParsing":true,"forcedJSONParsing":true,"clarifyTimeoutError":false},"transformRequest":[null],"transformResponse":[null],"timeout":15000,"xsrfCookieName":"XSRF-TOKEN","xsrfHeaderName":"X-XSRF-TOKEN","maxContentLength":-1,"maxBodyLength":-1,"headers":{"Accept":"application/json, text/plain, /","Content-Type":"application/json","X_USERNAME":"backend","X_PASSWORD":"qpd8pjk9jkb6WXK*zkc","X_ACCOUNT_CODE":"gooddollar_limited","X-Requested-With":"XMLHttpRequest","User-Agent":"axios/0.24.0","Content-Length":106},"baseURL":"https://api.ongage.net/api","method":"put","data":"{\"overwrite\":true,\"fields\":{\"last_claim\":\"2023/01/08\",\"claim_counter\":75},\"id\":\"626d75bf45bb0352e08b4568\"}","params":{},"url":"v2/contacts","logger":{},"axios-retry":{"retryCount":0,"lastRequestTime":1673195184170}},"status":412},{"url":"v2/contacts","body":"{\"overwrite\":true,\"fields\":{\"last_claim\":\"2023/01/08\",\"claim_counter\":75},\"id\":\"626d75bf45bb0352e08b4568\"}"}]}[39m

the reason is that contect with ID 626d75bf45bb0352e08b4568 not exists at OnGage. Unfortunately i’m not able to reach how it’s possible. I’ve found account of this guy in mongo. He created it 30/04/22 but first logs with his account id are starting from 04/01/23. There’re no logs about his signup, nor about any further events. Maybe he removed then recreated account. Need more cases.

johnsmith-gooddollar commented 1 year ago

@sirpy I've searched logs since 1 Jan 2022 - found only one more case. Both happened from 04/01/23 till today (12/01/23). Both have the same issue - contact not found. Both were created in the previous year (the second one at 02/08/22). Both have no logs about signup process.

account / crmId 0x3c304c7fc1b69ceba7c87f8350f999d47dc865fb 626d75bf45bb0352e08b4568 0xfc302220acbd314f71db58ac3b7d1d5b3c0ded13 61c7244e43bb039f778bb8c0

P.S. It looks like Logenties had been cut records before 1/1/23 off - could it be possible ?

johnsmith-gooddollar commented 1 year ago

@sirpy The issue still appears but with the same accounts. As we don't have full history about them, we still cannot research for the reason possible.

No new cases found. It looks like we have a few accounts "broken". Should we do something with that ?

sirpy commented 1 year ago

@johnsmith-gooddollar i was filtering the logs by "ongage error" there are frequent 404 errors from contacts/by_email - according to the code it is supposed to ignore these errors

async getContactIdByEmail(email, logger) {
    try {
      const existingContact = await this.getContactByEmail(email, logger)

      return get(existingContact, 'payload.id')
    } catch (exception) {
      if (404 !== get(exception, 'response.data.payload.code')) {
        throw exception
      }
    }

so that seems broken.

otherwise we can close this issue after the above is fixed

johnsmith-gooddollar commented 1 year ago

hot fixed: https://github.com/GoodDollar/GoodServer/commit/538767a8988a7234dbf91bba3b5cf21d09b7d71c