pazaan / 600SeriesAndroidUploader

Your Medtronic 600-series pump data, direct to Nightscout
http://pazaan.github.io/600SeriesAndroidUploader/
MIT License
189 stars 312 forks source link

Dot character in basal pattern causes NS crash #254

Closed benceszasz closed 5 years ago

benceszasz commented 5 years ago

Brief Explanation of Issue

If there is a dot (".") character in the name of a basal pattern (for example "Day Off" is "Szab.nap") the profile creation causes MongoDB error during profile upload and also all profiles are lost in NS because of the delete command, which is executed before the create command. Heroku log:

app/web.1: GRANTED: XXX.XXX.XXX.XXX api-secret api:profile:read app/web.1: GRANTED: XXX.XXX.XXX.XXX api-secret api:profile:create app/web.1: got data-received event, requesting reload app/web.1: /app/node_modules/mongodb/lib/utils.js:132 app/web.1: throw err; app/web.1: ^ heroku/router: at=info method=GET path="/api/v1/treatments.json?find%5Bcreated_at%5D%5B%24gte%5D=2017&find%5Bkey600%5D=BASAL83852071" host=nightscouttst.herokuapp.com request_id=d2c0756f-69ac-4d65-84ae-d3d1d001aaa9 fwd="XXX.XXX.XXX.XXX" dyno=web.1 connect=0ms service=3ms status=200 bytes=398 protocol=https heroku/router: at=info method=GET path="/api/v1/treatments.json?find%5Bcreated_at%5D%5B%24gte%5D=2017&find%5Bkey600%5D=BOLUS83851C26" host=nightscouttst.herokuapp.com request_id=4af0f5b4-8b84-441a-8645-757db42e8495 fwd="XXX.XXX.XXX.XXX" dyno=web.1 connect=1ms service=3ms status=200 bytes=398 protocol=https heroku/router: at=info method=GET path="/api/v1/treatments.json?find%5Bcreated_at%5D%5B%24gte%5D=2017&find%5Bkey600%5D=MISC83851303" host=xxx.herokuapp.com request_id=d5351db7-8d10-43aa-9425-621dd1c8ca10 fwd="XXX.XXX.XXX.XXX" dyno=web.1 connect=1ms service=4ms status=200 bytes=398 protocol=https heroku/web.1: State changed from up to crashed app/web.1: TypeError: Cannot read property 'ops' of null app/web.1: at /app/lib/api/profile/index.js:44:38 app/web.1: at /app/lib/server/profile.js:9:7 app/web.1: at err (/app/node_modules/mongodb/lib/utils.js:411:14) app/web.1: at session.endSession (/app/node_modules/mongodb/lib/utils.js:397:27) app/web.1: at ClientSession.endSession (/app/node_modules/mongodb-core/lib/sessions.js:134:41) app/web.1: at executeCallback (/app/node_modules/mongodb/lib/utils.js:395:17) app/web.1: at bulkWrite (/app/node_modules/mongodb/lib/operations/collection_ops.js:926:21) app/web.1: at bulk.execute (/app/node_modules/mongodb/lib/operations/collection_ops.js:133:14) app/web.1: at err (/app/node_modules/mongodb/lib/utils.js:411:14) app/web.1: at executeCallback (/app/node_modules/mongodb/lib/utils.js:401:25) heroku/router: at=info method=GET path="/api/v1/treatments.json?find%5Bcreated_at%5D%5B%24gte%5D=2017&find%5Bkey600%5D=BOLUS838514AD" host=xxx.herokuapp.com request_id=a52f5373-5478-440d-a89b-62b9ba3ab0da fwd="XXX.XXX.XXX.XXX" dyno=web.1 connect=0ms service=3ms status=200 bytes=398 protocol=https heroku/web.1: Process exited with status 1 heroku/router: at=error code=H13 desc="Connection closed without response" method=POST path="/api/v1/profile" host=xxx.herokuapp.com request_id=cd945b8b-8611-4593-bf31-3137eac8d402 fwd="XXX.XXX.XXX.XXX" dyno=web.1 connect=1ms service=14ms status=503 bytes=0 protocol=https

Uploader Error Code

(processProfile) Service Unavailable

Steps to Reproduce (for bugs)

  1. Put a dot character in the name of a basal pattern
  2. Execute basal pattern update

Severity Score

Hungarian version is not working, but I will change the translation so there will be no more dots in the default Hungarian basal pattern names (for exmaple "Day Off" is "Szab.nap" in the Hungarian 640G), however if a user puts a dot in the name of the pattern the error will occur again.

Pogman commented 5 years ago

notes:

java.util.Map<K, V> is likely the cause here as K string in pairing may not handle dots and needs to be checked for other symbols that could cause issues.

A scrubbing function may be needed the at least sanitize this as a fix.

Pogman commented 5 years ago

On further checking and tests the json data is formed correctly for Nightscout and sent to the rest api. This indicates no issue with the map function (it's just a string after all) . It would seem that NS does not like this being sent through the api and returns no post response and indicates a server error.

The solution is still the same, scrub dots from the basal pattern name. The recommendation for translators is not to use a dot in the default basal names for your language.

Pogman commented 5 years ago

Released v0.7.1 has a fix for this. Please report if there is still a problem, thanks.