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

Obscure error is reported when OPENAI_API_KEY is not set #2

Closed
artemmukhin opened this issue Mar 29, 2023 · 1 comment · Fixed by #3
Closed

Obscure error is reported when OPENAI_API_KEY is not set #2

artemmukhin opened this issue Mar 29, 2023 · 1 comment · Fixed by #3

Comments

@artemmukhin
Copy link
Contributor

Prerequisites

macOS 13.2.1

$ echo $OPENAI_API_KEY

$ python3 --version
Python 3.10.10

$ python3 -m pip install chatdbg

Steps to reproduce

$ python3 -m chatdbg -c continue testme.py

ZeroDivisionError: division by zero
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> ~/chatdbg/test/testme.py(4)tryme()
-> if x / i > 2:
(ChatDBG Pdb) why
EXCEPTION 'choices'

(ChatDBG Pdb)

It starts working after setting OPENAI_API_KEY

$ export OPENAI_API_KEY=<key>

$ python3 -m chatdbg -c continue testme.py

ZeroDivisionError: division by zero
Uncaught exception. Entering post mortem debugging
Running 'cont' or 'step' will restart the program
> ~/chatdbg/test/testme.py(4)tryme()
-> if x / i > 2:
(ChatDBG Pdb) why
The root cause of the error is that the code tries to divide by zero.
This occurs in the `tryme` function where `range(100)` includes the
value 0, and the code tries to divide by 0 on the line `if x / i >
2:`.
artemmukhin added a commit to artemmukhin/ChatDBG that referenced this issue Mar 29, 2023
Fixes plasma-umass#2.

Previously, running `why` when `OPENAI_API_KEY` was not set led to an obscure message:
```
(ChatDBG Pdb) why
EXCEPTION 'choices'
```

This happened because `openai_async.chat_complete` does not raise `openai.error.AuthenticationError` when `openai.api_key` is `None`. To handle it, `None` is now replaced with an empty string literal.
@emeryberger
Copy link
Member

Thanks for the report and patch!

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 a pull request may close this issue.

2 participants