Commit a51a489
committed
fix: Always return response from _do_http_method
Noticed a bug where the *first* time we queried an API after a long time
(in this case Sierra), we'd see a json decode error coming from the
requests modules `response.json()`. Since we weren't calling it on our
end, I dug through the trace a little and found that we call `.json()`
in this library *only* when the token is expired and we do a refresh,
which would explain the timing of the bug.
So simply, make sure to return the raw response object when we do a
token refresh.
Here's an example stacktrace of the bug we are encountering:
File /ereadingserver/./app/main.py, line 186, in login
File /ereadingserver/./app/auth/login.py, line 62, in log_in_with_card
File /ereadingserver/./app/sierra.py, line 106, in patron_is_valid
File /usr/local/lib/python3.10/site-packages/nypl_py_utils/classes/oauth2_api_client.py, line 63, in post
File /usr/local/lib/python3.10/site-packages/nypl_py_utils/classes/oauth2_api_client.py, line 106, in _do_http_method
File /usr/local/lib/python3.10/site-packages/requests/models.py, line 975, in json1 parent 79b6d1b commit a51a489
4 files changed
Lines changed: 11 additions & 5 deletions
File tree
- src/nypl_py_utils/classes
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
2 | 5 | | |
3 | 6 | | |
4 | 7 | | |
| |||
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
15 | | - | |
| 18 | + | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
120 | | - | |
| 120 | + | |
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
124 | 127 | | |
125 | 128 | | |
126 | 129 | | |
| |||
0 commit comments