Ratasa143 opened a new pull request, #61942:
URL: https://github.com/apache/airflow/pull/61942
**Title:**
Fix pause/unpause CLI commands: validate `dag_id` and add local tests
**Description:**
This PR addresses issue #57721 by improving the behavior of the `pause` and
`unpause` commands in `airflowctl`.
**Changes Made:**
1. **Validation of `dag_id`:**
- Both `pause` and `unpause` now check if the required `dag_id` parameter
is provided.
- If missing, a clear error is raised, instructing the user to provide
`--dag-id` or check the help.
2. **Refactored common logic:**
- Introduced a helper function `update_dag_state()` to handle both pause
and unpause operations, reducing code duplication.
3. **Local testing script (`test_args.py`):**
- Tests CLI behavior for both missing and present `dag_id`.
- Confirms that pause/unpause succeeds when a valid `dag_id` is provided.
- Confirms that appropriate errors are raised when `dag_id` is missing.
4. **Improved output formatting:**
- Results from pause/unpause operations are printed in a clear,
human-readable format.
- Includes DAG details for verification.
**Testing:**
- Local tests run successfully:
- Missing `dag_id` → raises user-friendly error
- Provided `dag_id` → DAG pause/unpause succeeds
- Tests use mock responses, so no real Airflow instance is required.
**Why This Matters:**
- Ensures CLI commands behave consistently.
- Provides clear feedback to users, improving the CLI experience.
- Reduces code duplication and prepares the codebase for easier maintenance.
**Fixes:** #57721
--
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]