Commit ac5e944
[ROB-3981] Don't force Azure Prometheus auth from partial env vars (HolmesGPT#2101)
## Summary
- `AzurePrometheusConfig.is_azure_config()` previously selected the
Azure variant whenever `AZURE_CLIENT_ID` or `AZURE_TENANT_ID` was set on
the pod — even when the user had a self-hosted `prometheus_url`
configured and `AZURE_CLIENT_SECRET` was missing. This is common when
Azure AI Foundry is the LLM provider: the `AZURE_*` env vars exist for
an unrelated subsystem, and Holmes failed the Prometheus toolset with a
confusing missing-credentials error.
- `is_azure_config` now mirrors the same completeness rule that
`AzurePrometheusConfig.__init__` already enforces: Azure mode is
selected only when `azure_use_managed_id` is enabled OR all three of
`azure_client_id` / `azure_tenant_id` / `azure_client_secret` are
resolvable (config field or upper-cased `AZURE_*` env var).
- A *partial* Azure signal (some creds present, others missing) now logs
a `WARNING` naming what was found vs. missing and falls back to plain
Prometheus, so the user immediately sees why Azure auth was skipped.
- New `get_config_field(config, field)` module-level helper centralizes
the "config dict, else upper-cased env var" lookup pattern.
- The credential field list is sourced from
`AzurePrometheusConfig._ui_required_fields` so the auto-detect check and
the UI form requirement stay in lockstep.
- The explicit `subtype: azure-managed-prometheus` opt-in path is
untouched — it still selects `AzurePrometheusConfig` directly and raises
the existing `ValueError` if credentials are incomplete.
## Test plan
- [x] `poetry run pytest tests/plugins/toolsets/test_prometheus_unit.py
--no-cov` — 28 passed (14 existing + 7 new `TestIsAzureConfig` + 7 new
`TestGetConfigField`).
- [x] Regression test asserts the user's exact scenario: with
`AZURE_CLIENT_ID` + `AZURE_TENANT_ID` exported (no secret) and a plain
`prometheus_url` in config, `determine_prometheus_class` returns
`PrometheusConfig` (not `AzurePrometheusConfig`) and emits a "Partial
Azure" warning.
- [x] Positive cases still pass: all three env vars set →
`AzurePrometheusConfig`; `azure_use_managed_id: true` in config or env →
`AzurePrometheusConfig`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **Bug Fixes**
* Improved Azure authentication validation to detect incomplete
credential configurations and log informative warnings instead of
silently failing.
* Enhanced configuration field resolution with environment variable
fallback support.
* **Tests**
* Expanded test coverage for configuration field handling and Azure
authentication detection scenarios.
<!-- review_stack_entry_start -->
[](https://app.coderabbit.ai/change-stack/HolmesGPT/holmesgpt/pull/2101?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)
<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Signed-off-by: avi@robusta.dev <avi@robusta.dev>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent d25c43a commit ac5e944
2 files changed
Lines changed: 180 additions & 10 deletions
File tree
- holmes/plugins/toolsets/prometheus
- tests/plugins/toolsets
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
77 | 77 | | |
78 | 78 | | |
79 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
80 | 88 | | |
81 | 89 | | |
82 | 90 | | |
| |||
536 | 544 | | |
537 | 545 | | |
538 | 546 | | |
539 | | - | |
540 | | - | |
541 | | - | |
542 | | - | |
543 | | - | |
544 | | - | |
545 | | - | |
546 | | - | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
| 558 | + | |
| 559 | + | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
| 565 | + | |
547 | 566 | | |
548 | | - | |
549 | | - | |
| 567 | + | |
550 | 568 | | |
551 | 569 | | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
552 | 585 | | |
553 | 586 | | |
554 | 587 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
3 | 5 | | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
4 | 9 | | |
| 10 | + | |
5 | 11 | | |
6 | 12 | | |
7 | 13 | | |
| |||
192 | 198 | | |
193 | 199 | | |
194 | 200 | | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
0 commit comments