Repository navigation
Validate map_index range in CLI commands - #62626
Conversation
|
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contributors' Guide (https://github.com/apache/airflow/blob/main/contributing-docs/README.rst)
|
When a user passes a map_index to CLI commands like `tasks render` or `tasks test`, validate that it falls within the parse-time mapped count. This gives a clear error message instead of silently proceeding with an invalid index. For dynamically mapped tasks (XCom-based), the validation is skipped since the count is not available at parse time. closes: apache#60463 Co-Authored-By: claude-flow <[email protected]>
a569059 to
7ad1cfd
Compare
SameerMesiah97
left a comment
There was a problem hiding this comment.
Approach is sound. I have left a few comments. Overall, this a well-justified, tightly scoped change.
|
Thanks @SameerMesiah97 for the review! Comment 1 (NotFullyPopulated/NotMapped split): Good point — Comment 2 (test pattern): Makes sense, Both changes pushed. |
Split the except block so NotMapped raises a ValueError instead of being silently ignored alongside NotFullyPopulated. Also switch the dynamic-mapping test to the standard pytest.raises pattern. Co-Authored-By: claude-flow <[email protected]>
Co-Authored-By: claude-flow <[email protected]>
|
The |
Replace `rich.print(pools_list)` with `AirflowConsole().print_as()` so non-JSON export formats (table, yaml, plain) are rendered consistently with other airflow-ctl commands. Add test verifying the delegation. Co-Authored-By: claude-flow <[email protected]>
This reverts commit 5dc87ee.
* Validate map_index range in CLI commands When a user passes a map_index to CLI commands like `tasks render` or `tasks test`, validate that it falls within the parse-time mapped count. This gives a clear error message instead of silently proceeding with an invalid index. For dynamically mapped tasks (XCom-based), the validation is skipped since the count is not available at parse time. closes: apache#60463 Co-Authored-By: claude-flow <[email protected]> * Raise clear error for map_index on non-mapped tasks Split the except block so NotMapped raises a ValueError instead of being silently ignored alongside NotFullyPopulated. Also switch the dynamic-mapping test to the standard pytest.raises pattern. Co-Authored-By: claude-flow <[email protected]> * Fix ruff format: collapse single-line raise ValueError Co-Authored-By: claude-flow <[email protected]> * Use AirflowConsole for non-JSON pool export output Replace `rich.print(pools_list)` with `AirflowConsole().print_as()` so non-JSON export formats (table, yaml, plain) are rendered consistently with other airflow-ctl commands. Add test verifying the delegation. Co-Authored-By: claude-flow <[email protected]> * Revert "Use AirflowConsole for non-JSON pool export output" This reverts commit 5dc87ee. --------- Co-authored-by: claude-flow <[email protected]>
* Validate map_index range in CLI commands When a user passes a map_index to CLI commands like `tasks render` or `tasks test`, validate that it falls within the parse-time mapped count. This gives a clear error message instead of silently proceeding with an invalid index. For dynamically mapped tasks (XCom-based), the validation is skipped since the count is not available at parse time. closes: apache#60463 Co-Authored-By: claude-flow <[email protected]> * Raise clear error for map_index on non-mapped tasks Split the except block so NotMapped raises a ValueError instead of being silently ignored alongside NotFullyPopulated. Also switch the dynamic-mapping test to the standard pytest.raises pattern. Co-Authored-By: claude-flow <[email protected]> * Fix ruff format: collapse single-line raise ValueError Co-Authored-By: claude-flow <[email protected]> * Use AirflowConsole for non-JSON pool export output Replace `rich.print(pools_list)` with `AirflowConsole().print_as()` so non-JSON export formats (table, yaml, plain) are rendered consistently with other airflow-ctl commands. Add test verifying the delegation. Co-Authored-By: claude-flow <[email protected]> * Revert "Use AirflowConsole for non-JSON pool export output" This reverts commit 5dc87ee. --------- Co-authored-by: claude-flow <[email protected]>
Validate
map_indexrange when creating task instances via CLI commands(
tasks render,tasks test, etc.) to provide a clear error instead ofsilently proceeding with an invalid index.
Changes:
_get_ti(), calltask.get_parse_time_mapped_ti_count()to checkthat
map_indexis within[0, count)when a non-negative index issupplied.
NotFullyPopulated/
NotMappedand skip validation since the count is not available atparse time.
skip.
closes: #60463
Was generative AI tooling used to co-author this PR?
following the guidelines