Skip to content

Make API keys optional & add code quality TODOs#91

Merged
Miyamura80 merged 1 commit into
mainfrom
feat/optional-api-keys
Jan 26, 2026
Merged

Make API keys optional & add code quality TODOs#91
Miyamura80 merged 1 commit into
mainfrom
feat/optional-api-keys

Conversation

@Miyamura80
Copy link
Copy Markdown
Owner

Summary

  • Make all 5 LLM API keys (OpenAI, Anthropic, Groq, Perplexity, Gemini) optional with None default
  • Add runtime validation in llm_api_key() that raises descriptive errors when a missing key is accessed
  • Add code quality issues to TODO.md with high/medium priority items

Test plan

  • make ci passes (ruff, vulture, ty, import linter)
  • make test passes (14 tests)
  • Manually verify app starts with only one API key configured

🤖 Generated with Claude Code

- Make all 5 LLM API keys optional with None default
- Add runtime validation in llm_api_key() with descriptive errors
- Add code quality issues to TODO.md (high/medium priority)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Jan 26, 2026

Greptile Overview

Greptile Summary

Made all 5 LLM API keys (OpenAI, Anthropic, Groq, Perplexity, Gemini) optional with None defaults, shifting from required environment variables to optional ones with runtime validation. When llm_api_key() is called for a provider whose key is not configured, it raises a descriptive ValueError indicating which environment variable needs to be set.

The PR also documents existing code quality issues in TODO.md, including the validator anti-pattern in the same file (common/global_config.py:188-198) where validators compute values from environment variables rather than validating inputs.

  • Made API keys optional to support apps that only need a subset of providers
  • Added clear error messages when accessing unconfigured keys at runtime
  • Documented 5 high-priority and 3 medium-priority technical debt items

Confidence Score: 4/5

  • Safe to merge with one minor syntax issue in error message formatting
  • The implementation correctly makes API keys optional and adds proper runtime validation. The logic is sound and the error messages are helpful. One syntax issue was identified in the error message construction. The test plan shows make ci and make test pass, though manual verification of single-key configuration is pending.
  • No files require special attention - the syntax issue in common/global_config.py should be addressed

Important Files Changed

Filename Overview
common/global_config.py Made 5 LLM API keys optional with None defaults and added runtime validation that raises descriptive errors when missing keys are accessed
TODO.md Added code quality section with 5 high-priority and 3 medium-priority technical debt items for future refactoring

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 file reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment thread common/global_config.py
Comment on lines +258 to +259
f"API key for provider '{provider}' is not configured. "
f"Set {provider.upper()}_API_KEY in your .env file."
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Error message inconsistency - this uses {provider.upper()}_API_KEY format, but actual env var names vary (e.g. OPENAI_API_KEY not openai_API_KEY). Suggestion uses the correct uppercase format.

Suggested change
f"API key for provider '{provider}' is not configured. "
f"Set {provider.upper()}_API_KEY in your .env file."
f"Set {provider.upper()}_API_KEY in your .env file."
Prompt To Fix With AI
This is a comment left during a code review.
Path: common/global_config.py
Line: 258:259

Comment:
Error message inconsistency - this uses `{provider.upper()}_API_KEY` format, but actual env var names vary (e.g. `OPENAI_API_KEY` not `openai_API_KEY`). Suggestion uses the correct uppercase format.

```suggestion
                    f"Set {provider.upper()}_API_KEY in your .env file."
```

How can I resolve this? If you propose a fix, please make it concise.

@Miyamura80 Miyamura80 merged commit f963c8d into main Jan 26, 2026
11 checks passed
@github-actions github-actions Bot deleted the feat/optional-api-keys branch January 26, 2026 21:38
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