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

Passing incorrect parameters to delete with RETRYING strategy can lead to endless loop #1163

Open
johbo opened this issue Dec 12, 2024 · 1 comment

Comments

@johbo
Copy link

johbo commented Dec 12, 2024

I've tried to use the conn.delete() to remove an entry from the directory and accidentally passed in wrong parameters, this did lead to an endless retry in the call to conn.delete().

Here is a code snippet out of a test case which I am using to run against my openldap server:

server = Server(
    host=self.host,
    port=self.port,
    get_info="ALL",
    connect_timeout=1,
)
conn = Connection(server, client_strategy="RETRYING", raise_exceptions=True)
users_container_dn = "cn=users,dc=organization,dc=intranet`
with conn:
    # Idea is to delete an entry if it exists, and otherwise ignore the exception if it does not exist
    try:
        # This line had the typo in the format string
        conn.delete(f"uid=test-user",{users_container_dn})
        # Correct would have been the following line:
        # conn.delete(f"uid=test-user,{users_container_dn}")
        print("deleted")
    except Exception:
        print("exception")

In the code above if the user entry does exist in the directory, then I don't see "deleted" and I also don't see "exception" being printed out. Instead it seems to be retrying in the conn.delete call.

Only after creating the ticket I've noticed the typo in my code. Even though the mistake was on the user side, this seems to be accidentally hiding this exception in the retrying loop.

@johbo johbo changed the title Using delete with RETRYING strategy can lead to endless loop Passing incorrect parameters to delete with RETRYING strategy can lead to endless loop Dec 12, 2024
@johbo
Copy link
Author

johbo commented Dec 12, 2024

I've noticed a tiny typo after creating this issue, going to update the description. Not sure if this is something to improve or even a case that could be closed as "won't fix".

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

1 participant