Skip to content

fix: clean error when OPENAI_API_KEY is unset in broker tools - #8

Draft
jayzuccarelli wants to merge 1 commit into
mainfrom
fix/tools-missing-key-error
Draft

fix: clean error when OPENAI_API_KEY is unset in broker tools#8
jayzuccarelli wants to merge 1 commit into
mainfrom
fix/tools-missing-key-error

Conversation

@jayzuccarelli

Copy link
Copy Markdown
Owner

Running any broker tool without OPENAI_API_KEY printed a raw KeyError traceback, because the key is read at import time with os.environ[...]. config.py already handles this properly.

Uses .get() plus a one-line SystemExit in the four tools that did it: harness, test_client, test_bargein, m2_play_ref.

Verified: python3 broker/tools/harness.py with no key now prints OPENAI_API_KEY is required and exits. Ruff is unchanged (the 2 remaining errors in broker/tools are pre-existing and outside CI's lint scope).

🤖 Generated with Claude Code

The tools read the key at import with os.environ[...], so running any of
them without a key dumped a raw KeyError traceback. Match config.py and
fail with the same one-line message instead.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6f167c2a-eb08-46c8-bf1e-b1600cead755

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/tools-missing-key-error

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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