FIX: AIRTInitializer container crash and parameters.example.json typo#1648
Conversation
| are populated. | ||
| Ensure operator and operation are populated in GLOBAL_MEMORY_LABELS. | ||
|
|
||
| Reads operator/operation from .pyrit_conf if it exists, then merges |
There was a problem hiding this comment.
Feels weird to do such strict enforcement but only if the file exists, and nothing otherwise.
In the GUI, it's plenty obvious that you should set them an if it's the deployed GUI it will auto-populate the operator anyway. I think the primary reason this exists is for enforcing these labels on scanner runs. Are those possible without conf file? If not, then I think this is fine.
There was a problem hiding this comment.
Good question! Yeah, scanner runs can work without .pyrit_conf. The original #1578 code didn’t enforce anything there either, it just crashed with a FileNotFoundError. So this change isn’t introducing a new gap, just turning a crash into a graceful skip.
Also, I believe all scanner examples use --initializers target load_default_datasets, not airt. The airt initializer is really only used by pyrit_backend for the GUI, where the operator gets set per-user at runtime. Happy to follow up if we want stricter label enforcement everywhere!
Description
Fixes two pre-existing bugs blocking Azure Container App deployments on current main.
AIRTInitializer crashes with FileNotFoundError when .pyrit_conf is missing. PR #1578 added _validate_operation_fields() which unconditionally opens ~/.pyrit/.pyrit_conf. This file does not exist in container deployments. The fix checks if the file exists before reading it, and skips gracefully in container/GUI mode where operator/operation are set per-user at runtime (PR #1636). This unblocks the test environment where new revisions have been ActivationFailed since Apr 10.
infra/parameters.example.json has "targets airt" but the valid initializer name is "target" (no s). Fixed the typo. Does not affect the pipeline (uses Bicep default) but would break manual deployments following the example.
Related to User Story #8520
Tests and Documentation
Added 4 unit tests for _validate_operation_fields():
test_validate_operation_fields_skips_when_pyrit_conf_missing
test_validate_operation_fields_preserves_existing_labels_when_pyrit_conf_missing
test_validate_operation_fields_merges_conf_into_labels
test_validate_operation_fields_does_not_overwrite_existing_labels
All 18 airt initializer tests pass. All 180 setup module tests pass. Ruff lint and format clean. E2E validated: backend starts with --initializers target airt and no .pyrit_conf, health check passes.
No documentation changes needed. No JupyText changes.