Skip to content

Fix UnboundLocalError in _get when CurlError is raised#66

Merged
lxcode merged 1 commit intostanfordio:mainfrom
Agnimandur:fix/curl-error-unbound-resp
Apr 20, 2026
Merged

Fix UnboundLocalError in _get when CurlError is raised#66
lxcode merged 1 commit intostanfordio:mainfrom
Agnimandur:fix/curl-error-unbound-resp

Conversation

@Agnimandur
Copy link
Copy Markdown
Contributor

Summary

  • Fixes an UnboundLocalError in Api._get() when a curl_cffi.curl.CurlError is raised (e.g. Send failure: Broken pipe).
  • The except block logged the error but fell through to code referencing resp, which was never assigned due to the exception. Added return None to exit early, consistent with the existing error-handling pattern for JSON decode failures.

Reproduction

2026-03-05 14:06:58.425 | ERROR    | truthbrush.api:_get:121 - Curl error: Failed to perform, curl: (55) Send failure: Broken pipe.
[14:07:00] cannot access local variable 'resp' where it is not associated with a value

Fix

Return None from the except CurlError block so execution doesn't fall through to self._check_ratelimit(resp) and resp.json() with an unbound variable.

Made with Cursor

@lxcode lxcode merged commit 0a91a9f into stanfordio:main Apr 20, 2026
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

Successfully merging this pull request may close these issues.

2 participants