CodeWithAsheville / court-notifications

GNU General Public License v3.0
11 stars 10 forks source link

2022-07-03: Fix Axios error "Request path contains unescaped characters" #148

Closed ejaxon closed 1 month ago

ejaxon commented 2 years ago

This was a recent error recorded by Rollbar with the traceback below. We need to make sure that the search string doesn't contain extraneous spaces (at least strip from the submitted names) and then run through URL function to escape anything needed. See this Stack Overflow and the documentation for URL.

Probably just fix in computeSearchUrl function, line 27 of search-court-records.js.

TypeError: Request path contains unescaped characters File "node:internal/errors", line 372, in new NodeError File "node:_http_client", line 160, in new ClientRequest File "node:https", line 353, in Object.request File "/app/node_modules/axios/lib/adapters/http.js", line 202, in dispatchHttpRequest var req = transport.request(options, function handleResponse(res) { File "", line unknown, in new Promise File "/app/node_modules/axios/lib/adapters/http.js", line 46, in httpAdapter return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) { File "/app/node_modules/axios/lib/core/dispatchRequest.js", line 53, in dispatchRequest return adapter(config).then(function onAdapterResolution(response) { File "/app/node_modules/axios-cookiejar-support/lib/index.js", line 41, in wrappedDispatchRequest return (0, _dispatchRequest.default)(config); File "/app/packages/server/search-court-records.js", line 38, in async getCasesPage let resp = await axiosInstance.get(url, {withCredentials: true}); File "/app/packages/server/search-court-records.js", line 102, in async searchCourtRecords let nextPage = await getCasesPage(axiosInstance, url, cases, false)

ejaxon commented 1 month ago

No longer relevant