fix(cli): align Azure provider env var with docs (prefer AZURE_OPENAI_API_KEY, accept legacy AZURE_OPENAI_KEY) - #23
Merged
Conversation
…_API_KEY, accept legacy AZURE_OPENAI_KEY) Aligns the CLI's Azure provider detection with the rest of the project. The README, architecture presentation, cheatsheet, upstream amplifier-module-provider-azure-openai, and Azure OpenAI Python SDK all use AZURE_OPENAI_API_KEY, but the CLI was only honoring AZURE_OPENAI_KEY. After this change, the CLI prefers AZURE_OPENAI_API_KEY, accepts AZURE_OPENAI_KEY as a deprecated legacy alias with a one-time [WARN] on stderr, and preserves detection precedence (ANTHROPIC_API_KEY > OPENAI_API_KEY > AZURE_OPENAI_API_KEY > OLLAMA_HOST). Mirrors the upstream Azure provider module's dual-accept pattern (see __init__.py lines 119-120), which already prefers AZURE_OPENAI_API_KEY and falls back to AZURE_OPENAI_KEY. Verification: python_check clean on all 8 changed .py files, 53 tests pass on targeted test suite, full pytest shows same 23 pre-existing failures as origin/main (+2 new tests passing, no new failures). Manual verification confirms detection works with both spellings, legacy fallback triggers deprecation warning. Separate from PR #22 (version-info-and-error-message). 🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier) Co-Authored-By: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What. Aligns the CLI's Azure provider detection with the rest of the project. The README, the architecture presentation, the cheatsheet, the upstream
amplifier-module-provider-azure-openaimodule, and the Azure OpenAI Python SDK all spell the credential asAZURE_OPENAI_API_KEY, butprovider_detectandprovider_sourceswere the only place still honoring the olderAZURE_OPENAI_KEYspelling. After this change the CLI prefersAZURE_OPENAI_API_KEY, keeps detection precedence intact (ANTHROPIC_API_KEY→OPENAI_API_KEY→AZURE_OPENAI_API_KEY→OLLAMA_HOST), and acceptsAZURE_OPENAI_KEYas a deprecated legacy alias that triggers a one-time[WARN]on stderr.Why. Surfaced by a reality check on amplifier-agent: a user following the documented setup (
export AZURE_OPENAI_API_KEY=…) would haveamplifier-agent doctorreport "provider not configured" becauseprovider_detectonly checkedAZURE_OPENAI_KEY. Dual-accept was chosen over a clean rename because the upstream Azure provider module itself already accepts both spellings (preferringAZURE_OPENAI_API_KEY, falling back toAZURE_OPENAI_KEY— seeamplifier_module_provider_azure_openai/__init__.pylines 119–120), so mirroring that behavior in the CLI fixes the user-facing bug without breaking anyone currently using the legacy var, and gives us a one-release deprecation window. The legacy alias and its warning are trivially removable in a future PR. Separate from PR #22 (version-info-and-error-message).How verified.
python_check(ruff + pyright + stub-check + format) is clean on all 8 changed.pyfiles. Targeted pytest on the 5 touched test files: 53 passed (including 2 new tests covering the legacy-fallback path and the preferred-over-legacy precedence). Full pytest-m "not integration"shows the same 23 pre-existing failures that exist onorigin/main— no new failures introduced,+2passing count from the new tests. Manual: withAZURE_OPENAI_API_KEY=fakeset and the other provider vars unset,amplifier-agent doctornow reports[ OK ] provider: azure-openai(no warning); with the legacyAZURE_OPENAI_KEYset, doctor still detects Azure and emits the[WARN] AZURE_OPENAI_KEY is deprecated…line on stderr exactly once.