Skip to content

Conversation

@harshil0014
Copy link
Collaborator

Problem
call_on_each_event aggressively retries on errors. For client-side errors like
{"result":"error","code":"UNAUTHORIZED"} (bad/expired API key) or
{"code":"BAD_REQUEST"} (invalid params/narrow), this hides the issue and appears
to “silently fail”. This matches the feedback thread linked from the issue.

Change
In Client.call_on_each_event (zulip/zulip/init.py), after the network-exception
handlers and before the existing error branch, detect:

if res.get("result") == "error":
    code = res.get("code")
    if code in ("UNAUTHORIZED", "BAD_REQUEST"):
        raise ZulipError(f"{code}: {res.get('msg', '')}")

@harshil0014
Copy link
Collaborator Author

Hi! I’ve opened a PR (#882) implementing the fail-fast behavior discussed.
call_on_each_event now raises ZulipError immediately on UNAUTHORIZED/BAD_REQUEST.

if code in ("UNAUTHORIZED", "BAD_REQUEST"):
# UNAUTHORIZED -> bad/expired credentials
# BAD_REQUEST -> invalid parameters (often bad narrow)
raise ZulipError(f"{code}: {res.get('msg', '')}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic clearly belongs in the next elif block, not here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants