DoSomethingArchive / gambit-content

:black_joker: Content API for Gambit
MIT License
2 stars 5 forks source link

Handle POST reportback errors (Members stuck in 'Reason_Why' Loop) #771

Closed jamjensen closed 7 years ago

jamjensen commented 7 years ago

BUG

Current Behavior

Desired Behavior

Steps to Replicate

Why This Matters

Relevant Screenshots + Links

image

image

image

User affected by bug on the 19th -

image

aaronschachter commented 7 years ago

Wanted to see if I could replicate this as a staffer, but I received the reportback confirmation message after texting back my why participated, as expected.

Suggested next steps on this one:

aaronschachter commented 7 years ago

I'm getting this on Thor when reporting back for Mirror Messages, it will happen when a POST Reportback to Phoenix fails, because Gambit isn't handling the POST Reportback error. Since no error is returned, Gambit posts a blank payload to the Mobile Commons API. Mobile Commons then returns the last saved gambit_chatbot_response field to the end user (which is why the ask_why message keeps repeating).

017-01-31T19:50:57.923426+00:00 app[web.1]: info: loaded user:5547be89469c64ec7d8b518d
2017-01-31T19:50:58.316428+00:00 app[web.1]: info: loaded signup:2812178
2017-01-31T19:50:58.317118+00:00 app[web.1]: warn: no messages sent from continueReportbackSubmission
2017-01-31T19:51:00.239421+00:00 app[web.1]: error: Cannot parse API response.
2017-01-31T19:51:00.243101+00:00 app[web.1]: error: campaignBot.campaign:7 user:5547be89469c64ec7d8b518d postReportback Error: Cannot parse API response.:undefined
2017-01-31T19:51:00.246090+00:00 app[web.1]: info: mobilecommons.profile_update profile:136122001 oip:214465 update:{}

Refs: https://dosomething.slack.com/archives/team-odoyle/p1485890863000646

aaronschachter commented 7 years ago

The POST campaigns/:id/reportback response just prints the string \n\nnull for my user.

screen shot 2017-02-01 at 7 40 40 am

I was hoping this was only happening on certain campaigns because of translation/run misconfiguration -- but it seems to be occurring for all staigng campaigns (ones that have proper translations, like Get Lucky id:2900). I was able to successfully reportback on a production campaign (texting LETTER)

aaronschachter commented 7 years ago

@chloealee made a configuration change to Thor that's fixed the POST reportbacks response.

The chatbot route isn't returning an error code back to Mobile Commons, which is why it repeats the "Ask Why" message over and over. Technically we should change this to return an error code, so the end user gets the "Sorry, something went wrong" message -- although if the POST request keeps failing, they'll just get that error response back over and over. It makes sense to close out this issue by handling the error (instead of just returning the existing gambit_chatbot_response value via the Opt-in path)

aaronschachter commented 7 years ago

@jamjensen Not sure why this happened in December as its issue on the Phoenix end, could potentially have been a similar configuration issue. We'd be able to find users this affected by checking the failed_at property in the reportback_submissions collection. Once the endpoint works though, the next time a user texts in the keyword -- Gambit tries to resubmit the reportback. This won't work if the Campaign has been closed since though.

aaronschachter commented 7 years ago

This is happening again on Thor -- posting reportbacks are failing. Perhaps due to the DB refresh from Friday.

2017-02-19T18:20:35.591653+00:00 app[web.1]: debug: Signup.postDraftReportbackSubmission data:{"source":"sms-mobilecommons","uid":1176550,"quantity":8,"caption":"Linkin park","file_url":"https://s3.amazonaws.com/mms.mcommons.com/mms/3118045/oSZyWW1tdxDxX0ns"} 2017-02-19T18:20:37.359502+00:00 heroku[router]: at=info method=POST path="/v1/chatbot" host=ds-mdata-responder-staging.herokuapp.com request_id=a775f697-46aa-4658-8a38-b224fc44b1d1 fwd="64.22.127.230" dyno=web.1 connect=0ms service=2090ms status=200 bytes=226 2017-02-19T18:20:37.350279+00:00 app[web.1]: error: Cannot parse API response. 2017-02-19T18:20:37.353641+00:00 app[web.1]: error: campaignBot.campaign:2070 user:5547be89469c64ec7d8b518d postReportback Error: Cannot parse API response.:undefined 2017-02-19T18:20:37.356467+00:00 app[web.1]: debug: saved user.current_campaign:2070

aaronschachter commented 7 years ago

Per https://github.com/DoSomething/gambit/issues/771#issuecomment-276699658, closed this issue in #791 by fixing the check for failed POST Reportback requests. The user ends up in an endless loop of mData error messages instead of an endless loop of the last gambit_chatbot_response they received:

img_2835