Skip to content

fix: let LogBatcherParser fall back to OPENAI_API_KEY - #360

Open
viktorbeck98 wants to merge 1 commit into
mainfrom
fix/logbatcher-openai-api-key-env
Open

viktorbeck98 wants to merge 1 commit into
mainfrom
fix/logbatcher-openai-api-key-env

Conversation

@viktorbeck98

@viktorbeck98 viktorbeck98 commented Oct 12, 2026 •

Copy link
Copy Markdown
Collaborator

Task

Closes #356

Description

LogBatcherParser passed its api_key setting straight to the OpenAI client. The default is an empty string, and the client only reads OPENAI_API_KEY when api_key is None. So the environment variable was never used, and LogBatcherParser() failed on creation unless the key was written into the config.

An empty api_key is now passed as None, the same way base_url already is. A key set in the config still takes precedence over the environment variable.

Not changed here: the docs example still says to put the key in the YAML.

How Has This Been Tested?

  • 2 new tests: the environment fallback, which fails before the fix with the error from the issue, and config-over-environment precedence. Full suite passes.
  • The snippet from the issue now creates the parser.

prek ran locally but skipped both changed files. The top-level exclude: '.*.log' in .pre-commit-config.yaml also matches paths that only contain "log", such as parsers/logbatcher/, so no linter checked this change.

Checklist

  • This Pull-Request goes to the development branch.
  • I have successfully run prek locally.
  • I have added tests to cover my changes.
  • I have linked the issue-id to the task-description.
  • I have performed a self-review of my own code.

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

The parser passed its api_key setting to the OpenAI client as is. The
default is an empty string, and the client only reads OPENAI_API_KEY when
api_key is None. So the environment variable was never used, and
LogBatcherParser() failed on creation unless the key was in the config.

An empty api_key is now passed as None, the same way base_url already is.
A key set in the config still takes precedence.

Closes #356

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Base automatically changed from development to main October 13, 2026 07:29

This branch has not been deployed

No deployments
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