Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Running Merlin locally no longer requires an `app.yaml` configuration file
- Removed dead lgtm link
- Potential security vulnerabilities related to logging
- Bug where the `--task-status` and `--return-code` filters of `merlin detailed-status` only accepted filters in all caps
- Bug where absolute path was required in the broker password field

## [1.12.2]
Expand Down
4 changes: 2 additions & 2 deletions merlin/cli/commands/status.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ def add_parser(self, subparsers: ArgumentParser):
"--return-code",
action="store",
nargs="+",
type=str,
type=str.upper,
choices=VALID_RETURN_CODES,
help="Filter which tasks to display based on their return code",
)
Expand All @@ -225,7 +225,7 @@ def add_parser(self, subparsers: ArgumentParser):
"--task-status",
action="store",
nargs="+",
type=str,
type=str.upper,
choices=VALID_STATUS_FILTERS,
help="Filter which tasks to display based on their status",
)
Expand Down
29 changes: 29 additions & 0 deletions tests/unit/cli/commands/test_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,35 @@ def test_add_parser_sets_up_detailed_status_command(self, create_parser: Fixture
assert not args.no_prompts
assert args.detailed

def test_add_parser_normalizes_task_status_and_return_code_filters(self, create_parser: FixtureCallable):
"""
Test that the DetailedStatusCommand parser normalizes `--return-code` and `--task-status`
values to uppercase, regardless of input case.

Args:
create_parser: A fixture to help create a parser.
"""
command = DetailedStatusCommand()
parser = create_parser(command)

# Simulate user input with mixed/lowercase values
args = parser.parse_args(
[
"detailed-status",
"some_workspace",
"--return-code",
"success",
"Soft_Fail",
"--task-status",
"running",
"Failed",
]
)

# Both return_code and task_status should be uppercased
assert args.return_code == ["SUCCESS", "SOFT_FAIL"]
assert args.task_status == ["RUNNING", "FAILED"]

def test_process_command_with_valid_workspace_and_detailed_status(self, mocker):
mock_verify_filepath = mocker.patch("merlin.cli.commands.status.verify_filepath", side_effect=ValueError)
mock_verify_dirpath = mocker.patch("merlin.cli.commands.status.verify_dirpath", return_value="path/to/workspace")
Expand Down