medic / cht-core

The CHT Core Framework makes it faster to build responsive, offline-first digital health apps that equip health workers to provide better care in their communities. It is a central resource of the Community Health Toolkit.
https://communityhealthtoolkit.org
GNU Affero General Public License v3.0
468 stars 218 forks source link

Cannot read property 'outgoing_phone_replace' of undefined: sms.token.login.help #7735

Open mrjones-plip opened 2 years ago

mrjones-plip commented 2 years ago

Describe the bug I have a CHT deployment with RapidPro set up as an outbound messaging gateway for use with our token login setup. We had a second message defined in our translation file in the sms.token.login.help, but only wanted to send one SMS, instead of two. We deleted the sms.token.login.help from our translation files and SMS stopped being sent.

To Reproduce Steps to reproduce the behavior were never found. I tried many different ways, but could not, so this is my best guess:

  1. Configure RapidPro as an outbound gateway
  2. Set up Magic Links
  3. Add a translation key for sms.token.login.help
  4. Test and note that two SMS are sent for Magic Links (as expecte)
  5. Remove the sms.token.login.help from your translation files

Expected behavior SMS should continue to be sent, but only one is sent instead of two.

Logs This is from logtrail:

Aug 17 02:06:43 [dev-test-cht-instance](https://logtrail.dev.medicmobile.org/app/logtrail#/?q=parse_error&h=dev-test-cht-instance&t=Now&i=logstash-*&_g=()) dev-test-cht-instance-haproxy: (dev-test-cht-instance-84798d49f4-z7l74) | Aug 17 09:06:43 dev-test-cht-instance-84798d49f4-z7l74 haproxy[25]: 127.0.0.1,201,PUT,/medic/token%3Alogin%3Aoi%3A.%3A75sMixRVq5m%2ClRTidf%2CB3H5Hi%3Agleiq19wsm6h%3A%3DXMjbKoM8G2ogpTeESos,api,medic-api,'{"_id":"token:login:oi:.:75sMixRKoM8G2ogpTeESos","type":"token_login","reported_date":1660727203553,"user":"org.couchdb.user:test","tasks":[],"errors":[{"message":"Cannot read property 'outgoing_phone_replace' of undefined: sms.token.login.help","code":"parse_error"}]}',565,22,139,'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)'
Aug 17 02:19:19 [dev-test-cht-instance](https://logtrail.dev.medicmobile.org/app/logtrail#/?q=parse_error&h=dev-test-cht-instance&t=Now&i=logstash-*&_g=()) dev-test-cht-instance-haproxy: (dev-test-cht-instance-84798d49f4-z7l74) | Aug 17 09:19:19 dev-test-cht-instance-84798d49f4-z7l74 haproxy[25]: 127.0.0.1,201,PUT,/medic/token%3Alogin%3AmDMxo6QLrzNHM7uAOav9B3q-lNXCryfgC%3De6D%3DPSzkQhdT!H2XZdxoqoX1Vn2m1.,api,medic-api,'{"_id":"token:login:mDMxo6QLoqoX1Vn2m1.","type":"token_login","reported_date":1660727959245,"user":"org.couchdb.user:testtest","tasks":[],"errors":[{"message":"Cannot read property 'outgoing_phone_replace' of undefined: sms.token.login.help","code":"parse_error"}]}',565,24,139,'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)'
Aug 17 02:44:26 [dev-test-cht-instance](https://logtrail.dev.medicmobile.org/app/logtrail#/?q=parse_error&h=dev-test-cht-instance&t=Now&i=logstash-*&_g=()) dev-test-cht-instance-haproxy: (dev-test-cht-instance-84798d49f4-z7l74) | Aug 17 09:44:26 dev-test-cht-instance-84798d49f4-z7l74 haproxy[25]: 127.0.0.1,201,PUT,/medic/token%3Alogin%3Afz%24oONehfQ.1CEfIwOMEqaYdjoWsHuO0Bh0RuqekQP9azonk2O2HIzcF5uDghH2%3D,api,medic-api,'{"_id":"token:login:fz$oONehfk2O2HIzcF5uDghH2=","type":"token_login","reported_date":1660729466663,"user":"org.couchdb.user:testtest","tasks":[],"errors":[{"message":"Cannot read property 'outgoing_phone_replace' of undefined: sms.token.login.help","code":"parse_error"}]}',563,17,139,'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)'
Aug 17 02:57:04 [dev-test-cht-instance](https://logtrail.dev.medicmobile.org/app/logtrail#/?q=parse_error&h=dev-test-cht-instance&t=Now&i=logstash-*&_g=()) dev-test-cht-instance-haproxy: (dev-test-cht-instance-84798d49f4-z7l74) | Aug 17 09:57:04 dev-test-cht-instance-84798d49f4-z7l74 haproxy[25]: 127.0.0.1,201,PUT,/medic/token%3Alogin%3A4n%24Gp25wxpzxct%24vQ7%3A0t0%24fS!HJd9bI%3DNx82qkmATDqnr%24Bw%24-Hbg%2C5dGVXMmrf,api,medic-api,'{"_id":"token:login:4n$Gp25wxpGVXMmrf","type":"token_login","reported_date":1660730224870,"user":"org.couchdb.user:testtest","tasks":[],"errors":[{"message":"Cannot read property 'outgoing_phone_replace' of undefined: sms.token.login.help","code":"parse_error"}]}',575,14,139,'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)'
Aug 17 07:21:08 [dev-test-cht-instance](https://logtrail.dev.medicmobile.org/app/logtrail#/?q=parse_error&h=dev-test-cht-instance&t=Now&i=logstash-*&_g=()) dev-test-cht-instance-haproxy: (dev-test-cht-instance-84798d49f4-z7l74) | Aug 17 14:21:08 dev-test-cht-instance-84798d49f4-z7l74 haproxy[25]: 127.0.0.1,201,PUT,/medic/token%3Alogin%3AR2WiD4pknzK1zE62fhnJLk%24N4lVcCIsAf%3Ds%2C59Jae39liiPILn%2Czcz8VEywSpDyT,api,medic-api,'{"_id":"token:login:R2WiD4pz8VEywSpDyT","type":"token_login","reported_date":1660746068373,"user":"org.couchdb.user:testtest","tasks":[],"errors":[{"message":"Cannot read property 'outgoing_phone_replace' of undefined: sms.token.login.help","code":"parse_error"}]}',567,16,139,'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)'
Aug 17 07:27:28 [dev-test-cht-instance](https://logtrail.dev.medicmobile.org/app/logtrail#/?q=parse_error&h=dev-test-cht-instance&t=Now&i=logstash-*&_g=()) dev-test-cht-instance-haproxy: (dev-test-cht-instance-84798d49f4-z7l74) | Aug 17 14:27:28 dev-test-cht-instance-84798d49f4-z7l74 haproxy[25]: 127.0.0.1,201,PUT,/medic/token%3Alogin%3AOq8qRzsfjRXY2dLaJPzoDFTKFw5cJP!3wMdEThE%24Uy%3AcnXL%2CZ1ewQD%3A9zawIrn-D,api,medic-api,'{"_id":"token:login:Oq8qRzswQD:9zawIrn-D","type":"token_login","reported_date":1660746448238,"user":"org.couchdb.user:medic-test-mrjones","tasks":[],"errors":[{"message":"Cannot read property 'outgoing_phone_replace' of undefined: sms.token.login.help","code":"parse_error"}]}',565,25,139,'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)'
Aug 17 07:53:42 [dev-test-cht-instance](https://logtrail.dev.medicmobile.org/app/logtrail#/?q=parse_error&h=dev-test-cht-instance&t=Now&i=logstash-*&_g=()) dev-test-cht-instance-haproxy: (dev-test-cht-instance-84798d49f4-z7l74) | Aug 17 14:53:42 dev-test-cht-instance-84798d49f4-z7l74 haproxy[25]: 127.0.0.1,201,PUT,/medic/token%3Alogin%3AtDAz0.VKg!5bcAX%3AV7lm.h%24ikzIG5V5p2qCqL4wemRfp%2CzWw2D5jXbm!cTW.m18%3D,api,medic-api,'{"_id":"token:login:tDAz0.VTW.m18=","type":"token_login","reported_date":1660748022018,"user":"org.couchdb.user:medic-test-mrjones","tasks":[],"errors":[{"message":"Cannot read property 'outgoing_phone_replace' of undefined: sms.token.login.help","code":"parse_error"}]}',569,21,139,'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)'

NB - I truncated all of the "_id":"token:login:* values, just to be safe. I also replaced the instance name with a place holder.

Screenshots NA

Environment

Additional context A lot more details available on this ticket (private repo). The work around was to push and empty value for sms.token.login.help in both translation files (English and French) that looked like this:

sms.token.login.help = 
mrjones-plip commented 2 years ago

cc @m5r and @jdndiaye