Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Iteration fails for retrieving PagerDuty response plays #61

Closed
defiant214 opened this issue May 1, 2021 · 2 comments
Closed

Iteration fails for retrieving PagerDuty response plays #61

defiant214 opened this issue May 1, 2021 · 2 comments

Comments

@defiant214
Copy link

Receive TypeError when doing the following

>>> rp = list(session.iter_all("response_plays"))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Users\[user]\AppData\Local\Programs\Python\Python39\lib\site-packages\pdpyras.py", line 1058, in iter_all
    offset += data['limit']
TypeError: unsupported operand type(s) for +=: 'int' and 'NoneType' ```

Same error occurs with list_all and dict_all. Able to receive list via rget method only
@Deconstrained
Copy link
Collaborator

Cool; thanks for pointing this out.

The response plays API is returning null values for limit and offset in the body, which is not expected. So, in other words, this is a bug in the API itself. I've submitted a ticket to the appropriate team that owns this API.

For context: the client by design sets the limit to the limit returned by the API (if it's present in the response body) and increments the offset by that limit if the limit is present in the response. That is for cases where the requested limit is greater than the maximum limit. This prevents incrementing offset by more than the actual page size, so that records won't be skipped over.

Deconstrained added a commit that referenced this issue May 13, 2021
The response plays API has been returning null values for offset and limit in its body. By trusting these values from the API, the client set itself up for a TypeError (see #61).

This fixes the issue by incrementing offset by the length of the array of results returned by the index instead of the value reported by the API.
@Deconstrained
Copy link
Collaborator

Backwards-compatible workaround implemented in 4.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants