fix: validate API keys on AgenticManager init #57

Merged
Snider merged 1 commit from fix/validate-api-keys-on-init into main 2026-02-23 11:41:13 +00:00
Member

Summary

  • Add Log::warning() in AgenticManager::registerProviders() for each provider registered without an API key
  • Misconfiguration is now surfaced at boot time with a message naming the env var to set, rather than silently failing on the first API call
  • Providers without a key remain registered but report isAvailable() = false, preserving backward compatibility

Changes

  • Services/AgenticManager.php - three Log::warning() checks before provider instantiation; inline docblock lists the three env vars
  • tests/Unit/AgenticManagerTest.php - new API key validation warnings describe block (7 test cases); updated handles missing configuration gracefully to also assert 3 warnings are logged
  • TODO.md - mark DX-002 resolved

Test plan

  • ./vendor/bin/pest --filter=AgenticManager passes
  • Warning appears in application logs when a provider key is missing
  • No warning when all three env vars are set

Closes #29

Generated with Claude Code

## Summary - Add `Log::warning()` in `AgenticManager::registerProviders()` for each provider registered without an API key - Misconfiguration is now surfaced at boot time with a message naming the env var to set, rather than silently failing on the first API call - Providers without a key remain registered but report `isAvailable() = false`, preserving backward compatibility ## Changes - `Services/AgenticManager.php` - three `Log::warning()` checks before provider instantiation; inline docblock lists the three env vars - `tests/Unit/AgenticManagerTest.php` - new `API key validation warnings` describe block (7 test cases); updated `handles missing configuration gracefully` to also assert 3 warnings are logged - `TODO.md` - mark DX-002 resolved ## Test plan - [ ] `./vendor/bin/pest --filter=AgenticManager` passes - [ ] Warning appears in application logs when a provider key is missing - [ ] No warning when all three env vars are set Closes #29 Generated with [Claude Code](https://claude.com/claude-code)
Clotho added 1 commit 2026-02-23 11:40:30 +00:00
fix: validate API keys on AgenticManager init (#29)
Some checks failed
CI / PHP 8.3 (pull_request) Failing after 1m47s
CI / PHP 8.4 (pull_request) Failing after 1m46s
c315fc43c6
Log a warning for each AI provider registered without an API key so
that misconfiguration is surfaced at boot time (not silently on the
first API call).  Each message names the environment variable to set:

  ANTHROPIC_API_KEY  – Claude
  GOOGLE_AI_API_KEY  – Gemini
  OPENAI_API_KEY     – OpenAI

Providers without a key remain registered but are marked unavailable
via isAvailable(), preserving backward compatibility.

- Add Log::warning() calls in registerProviders() for empty keys
- Extend AgenticManagerTest with a dedicated 'API key validation
  warnings' describe block (7 new test cases)
- Update DX-002 in TODO.md as resolved

Closes #29

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Snider merged commit 5fa46104f4 into main 2026-02-23 11:41:13 +00:00
Snider deleted branch fix/validate-api-keys-on-init 2026-02-23 11:41:13 +00:00
Sign in to join this conversation.
No description provided.