Skip to content

Fix UnboundLocalError in Prompt._handle_error on 400 responses - #29

Open
argjendhaxhiu wants to merge 1 commit into
future-agi:mainfrom
argjendhaxhiu:fix-prompt-unboundlocalerror
Open

argjendhaxhiu wants to merge 1 commit into
future-agi:mainfrom
argjendhaxhiu:fix-prompt-unboundlocalerror

Conversation

@argjendhaxhiu

Copy link
Copy Markdown

A 400 response whose body fails response.json() leaves detail unbound, so it masks the real API error with an UnboundLocalError instead. Hit this live calling Prompt.get_template_by_name(). Fix initializes detail = None up front and guards the later .get() calls.

detail was only assigned inside the try block, so if response.json()
failed it stayed unbound while still being referenced in every branch
below (TemplateAlreadyExists, the "No version found for label" check,
and the final SDKException). This masked the real API error with an
UnboundLocalError instead of a useful message.

Initialize detail = None up front and guard each .get() call so it
fails safely instead.

Reproduced live via Prompt.get_template_by_name() on a real 400 response.
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.

1 participant