nonprofittechy / docassemble-ssareportchangesletter

An interview to help an SSI or SSDI recipient report changes to the Social Security Administration
MIT License
1 stars 2 forks source link

Searching for nearby SSA offices crashes the interview #29

Closed BryceStevenWilley closed 1 year ago

BryceStevenWilley commented 1 year ago

The URL in the code (https://services6.arcgis.com/zFiipv75rloRP5N4/ArcGIS/rest/services/Office_Points/FeatureServer/1/query) in invalid now, so the interview crashes when it tries to get nearby offices. Found the error on production.

I'll try for a quick patch, but I don't know the full extent of the interview needing nearby SSA offices.

Full error
There was an error in the CourtFormsOnline application.

The error message was:

JSONDecodeError: 

    JSONDecodeError: [Errno Expecting value] Bad Request: 0

Traceback (most recent call last):
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/requests/models.py", line 910, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/flask/app.py", line 1523, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/flask/app.py", line 1509, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble/webapp/server.py", line 8061, in index
    interview.assemble(user_dict, interview_status, old_user_dict, force_question=special_question)
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble/base/parse.py", line 8296, in assemble
    raise the_error
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble/base/parse.py", line 8083, in assemble
    question_result = self.askfor(missingVariable, user_dict, old_user_dict, interview_status, seeking=interview_status.seeking, follow_mc=follow_mc, seeking_question=seeking_question)
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble/base/parse.py", line 8861, in askfor
    question_result = self.askfor(newMissingVariable, user_dict, old_user_dict, interview_status, variable_stack=variable_stack, questions_tried=questions_tried, seeking=seeking, follow_mc=follow_mc, recursion_depth=recursion_depth, seeking_question=seeking_question)
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble/base/parse.py", line 8746, in askfor
    exec_with_trap(question, user_dict)
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble/base/parse.py", line 9366, in exec_with_trap
    exec(the_question.compute, the_dict)
  File "", line 1, in 
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble/ssareportchangesletter/ssa.py", line 33, in load_offices
    results = self.searcher.nearest_offices(address, distance=distance)
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble/ssareportchangesletter/ssa.py", line 135, in nearest_offices
    return self.nearest_offices_by_lat_lng(address.location.latitude,address.location.longitude, distance=distance)
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble/ssareportchangesletter/ssa.py", line 126, in nearest_offices_by_lat_lng
    jdata = r.json()
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/requests/models.py", line 917, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: [Errno Expecting value] Bad Request: 0

The referer URL was https://apps.suffolklitlab.org/run/ssareportchangesletter/

Traceback (most recent call last):
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/requests/models.py", line 910, in json
    return complexjson.loads(self.text, **kwargs)
  File "/usr/lib/python3.10/json/__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.10/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.10/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/flask/app.py", line 1523, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/flask/app.py", line 1509, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble/webapp/server.py", line 8061, in index
    interview.assemble(user_dict, interview_status, old_user_dict, force_question=special_question)
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble/base/parse.py", line 8296, in assemble
    raise the_error
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble/base/parse.py", line 8083, in assemble
    question_result = self.askfor(missingVariable, user_dict, old_user_dict, interview_status, seeking=interview_status.seeking, follow_mc=follow_mc, seeking_question=seeking_question)
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble/base/parse.py", line 8861, in askfor
    question_result = self.askfor(newMissingVariable, user_dict, old_user_dict, interview_status, variable_stack=variable_stack, questions_tried=questions_tried, seeking=seeking, follow_mc=follow_mc, recursion_depth=recursion_depth, seeking_question=seeking_question)
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble/base/parse.py", line 8746, in askfor
    exec_with_trap(question, user_dict)
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble/base/parse.py", line 9366, in exec_with_trap
    exec(the_question.compute, the_dict)
  File "", line 1, in 
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble/ssareportchangesletter/ssa.py", line 33, in load_offices
    results = self.searcher.nearest_offices(address, distance=distance)
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble/ssareportchangesletter/ssa.py", line 135, in nearest_offices
    return self.nearest_offices_by_lat_lng(address.location.latitude,address.location.longitude, distance=distance)
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/docassemble/ssareportchangesletter/ssa.py", line 126, in nearest_offices_by_lat_lng
    jdata = r.json()
  File "/usr/share/docassemble/local3.10/lib/python3.10/site-packages/requests/models.py", line 917, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: [Errno Expecting value] Bad Request: 0

The external hostname was apps.suffolklitlab.org
BryceStevenWilley commented 1 year ago

Can reproduce by going through the ssa_report_change interview (can't seem to get it to crash from the ssa_office_test though). Have tested the fix and it works in that interview, directly linking to the SSA locator.