SameerMesiah97 opened a new issue, #62392:
URL: https://github.com/apache/airflow/issues/62392

   ### Apache Airflow Provider(s)
   
   databricks
   
   ### Versions of Apache Airflow Providers
   
   `apache-airflow-providers-databricks >= 7.9.1`
   
   ### Apache Airflow version
   
   main
   
   ### Operating System
   
   Debian GNU/Linux 12 (bookworm)
   
   ### Deployment
   
   Other
   
   ### Deployment details
   
   _No response_
   
   ### What happened
   
   When using `DatabricksRunNowOperator` with `cancel_previous_runs=True` and 
without specifying either `job_id` or `job_name`, the task fails at execution 
time with a `KeyError`.
   
   The failure occurs immediately when the task is triggered.
   
   ### What you think should happen instead
   
   If `cancel_previous_runs=True` is set without specifying either `job_id` or 
`job_name`, the operator should raise a clear `AirflowException` explaining 
that a job identifier is required.
   
   Validation errors related to operator configuration should surface as 
explicit Airflow exceptions rather than raw Python exceptions.
   
   ### How to reproduce
   
   Create and trigger the following DAG:
    
   ```
   from datetime import datetime
   from airflow import DAG
   from airflow.providers.databricks.operators.databricks import 
DatabricksRunNowOperator
   
   with DAG(
       dag_id="databricks_cancel_previous_runs_keyerror_repro",
       start_date=datetime(2025, 1, 1),
       schedule=None,
       catchup=False,
   ) as dag:
   
       DatabricksRunNowOperator(
           task_id="trigger_keyerror",
           cancel_previous_runs=True,
       )
   ```
   
   **Observed Behaviour**
   
   The task fails immediately with a `KeyError`.
   
   ### Anything else
   
   While the configuration is invalid, the current behavior surfaces a raw 
`KeyError`, which is an internal Python exception. Other validation paths in 
`DatabricksRunNowOperator` raise `AirflowException` for invalid or conflicting 
parameters.
   
   Raising a consistent `AirflowException` in this scenario would align this 
branch with the operator’s existing validation behavior and provide clearer 
feedback to DAG authors.
   
   
   ### Are you willing to submit PR?
   
   - [x] Yes I am willing to submit a PR!
   
   ### Code of Conduct
   
   - [x] I agree to follow this project's [Code of 
Conduct](https://github.com/apache/airflow/blob/main/CODE_OF_CONDUCT.md)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to