Skip to content

Replace generic AirflowException in AzureBatchOperator input validation - #71981

Open
baha-bouali wants to merge 1 commit into
apache:mainfrom
baha-bouali:follow-up-exception-file
Open

Replace generic AirflowException in AzureBatchOperator input validation#71981
baha-bouali wants to merge 1 commit into
apache:mainfrom
baha-bouali:follow-up-exception-file

Conversation

@baha-bouali

@baha-boualibaha-bouali commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #71071

CONTEXT: get the operators/batch.py entry in generated/known_airflow_exceptions.txt removed entirely.

What changed

AzureBatchOperator._check_inputs() had 8 bare raise AirflowException(...) calls. Each now raises a specific exception instead, defined in a new providers/microsoft/azure/exceptions.py:

ConditionException
vm_publisher not providedAzureBatchVmPublisherMissingError
use_latest_verified_vm_image_and_sku without a complete image specAzureBatchLatestImageSpecIncompleteError
vm_publisher without vm_sku/vm_offer/vm_node_agent_sku_idAzureBatchVmImageSpecIncompleteError
Neither target_dedicated_nodes nor enable_auto_scaleAzureBatchPoolSizingMissingError
enable_auto_scale combined with explicit node countsAzureBatchPoolSizingConflictError
enable_auto_scale without auto_scale_formulaAzureBatchAutoScaleFormulaMissingError
batch_job_release_task without batch_job_preparation_taskAzureBatchJobPreparationTaskMissingError
Required pool/job/task parameters missingAzureBatchRequiredParametersMissingError

All 8 subclass AirflowException, so existing except AirflowException handling around this operator is unaffected. Message strings are unchanged — only the exception types differ.

The allowlist entry is now gone rather than reduced: the checker deletes the line when the count reaches 0.

image

Testing

  • New tests/unit/microsoft/azure/test_exceptions.py: 24 cases covering inheritance, raising, and catchability as AirflowException.
  • operators/test_batch.py: the 19 existing tests passed unmodified after the change, confirming base-class compatibility. They're now tightened to assert the specific exception, and 4 previously untested validation branches have coverage: 23 tests total.
Was generative AI tooling used to co-author this PR?
  • Yes
  • Assited by Claude Sonnet 5. Reviewed, written and tested by the submitter

Signed-off-by: baha-bouali <baha.bouali2020@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@baha-bouali