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

corrupt cursor in contacts list #13

Open
alexkunger opened this issue Dec 15, 2021 · 11 comments
Open

corrupt cursor in contacts list #13

alexkunger opened this issue Dec 15, 2021 · 11 comments

Comments

@alexkunger
Copy link

We were not able to use the python sdk to pull the full contact list. It would error in a bad iterator on the second page of results from the rest api.
We resolved the issue by adding a limit param to the list call and then running the request once and then removing the limit param and the full request succeeded.
It seem the cursor on your server was somehow corrupt and then when a new one was issued it resolved itself.
The error was persistent over multiple days until we added that limit param.

@dp-rufus
Copy link
Contributor

Thanks for the info and sorry you had problems. I will pass this on to the relevant team members for investigation

@alexkunger
Copy link
Author

@dp-rufus has this been investigated? it is now happening even more frequently

@dp-rufus
Copy link
Contributor

Hi Alex
To help me find this in our logs and figure the problem out, please can you confirm my understanding:

When this problem occurs (intermittent but increasingly frequent),

  • A request GET /api/v2/contacts (page 1) will appear to complete successfully
    • http 200 status code
    • 'items' array of contacts
    • plausible-looking 'cursor' value (a long string, not absent or null)
    • are you providing the optional owner_id parameter?
  • You then (quickly afterwards) request GET /api/v2/contacts?cursor=xxxxx for page 2
    • this request fails - in what manner?
    • what status code do you get?
    • do you get any error message in the json response?
  • By repeating request 1 with a limit value, you could 'trick' the API into returning a different cursor, and this cursor then worked successfully in request 2
    • what limit value are you using?

Thanks for your help

@alexkunger
Copy link
Author

We are using the python sdk python-dialpad==2.1.0. We call contacts = dp_client.contact.list(owner_id=x)

We get the following error:
500 Server Error: Internal Server Error for url: https://dialpad.com/api/v2/contacts?limit=25&owner_id=4526224355819520'

Stack trace:
"/usr/local/lib/python3.9/site-packages/dialpad/resources/contact.py line 20 in list", "/usr/local/lib/python3.9/site-packages/dialpad/resources/resource.py line 11 in request", "/usr/local/lib/python3.9/site-packages/dialpad/client.py line 74 in request", "/usr/local/lib/python3.9/site-packages/requests/models.py line 953 in raise_for_status"

We started with limit 25 but then that stopped working so we went to random between 20 and 30. That now no longer works. I think the cursors are getting corrupted somehow and then not being removed.

@dp-rufus
Copy link
Contributor

dp-rufus commented Feb 1, 2022

Thanks for the info, I've found your stacktraces on our side. Please bear with me while I figure out the root cause and how to address it (I don't think it's related to cursors, surprisingly)

@alexkunger
Copy link
Author

Great. Thank you. Looking forward to seeing the solution.

@dp-rufus
Copy link
Contributor

dp-rufus commented Feb 1, 2022

We're tracking the issue internally as DP-45739

In the meantime please consider adding retry logic on your side.

If you subclass DialpadClient you can attach a custom urllib3 Retry policy with an adaptor:

from urllib3.util import Retry
from requests.adapters import HTTPAdapter

retry_policy = Retry(.............................)
retry_adapter = HTTPAdapter(max_retries=retry_policy)

class BetterDialpadClient(DialpadClient):
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self._session.mount("https://", retry_adapter)

@alexkunger
Copy link
Author

alexkunger commented Feb 2, 2022 via email

@alexkunger
Copy link
Author

How is work on the fix going?

@alexkunger
Copy link
Author

any updates here?

@tinvaan
Copy link
Contributor

tinvaan commented Mar 20, 2023

Hey @alexkunger, looks like @dp-rufus is no longer active here. @bendialpad, is this something you can triage with your team?

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

3 participants