From 9e27bb46b878635236e2b2e8c811c1181c3ae363 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 5 Aug 2026 00:02:45 +0000 Subject: [PATCH 1/4] Initial plan From 3a24ea6fc16e893157bb4656489f8a812101744b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 5 Aug 2026 00:10:17 +0000 Subject: [PATCH 2/4] {PostgreSQL} Fix maintenance-event list TypeError with --ids Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com> --- src/azure-cli/HISTORY.rst | 1 + .../cli/command_modules/postgresql/_params.py | 1 + .../unit/test_maintenance_event_params.py | 30 +++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 src/azure-cli/azure/cli/command_modules/postgresql/tests/unit/test_maintenance_event_params.py diff --git a/src/azure-cli/HISTORY.rst b/src/azure-cli/HISTORY.rst index f091f159e11..a187ad4d135 100644 --- a/src/azure-cli/HISTORY.rst +++ b/src/azure-cli/HISTORY.rst @@ -74,6 +74,7 @@ Release History * `az postgres flexible-server backup create`: Fix duplicate auto-generated backup names after deletions (#33684) * `az postgres flexible-server create`: Add example to create elastic cluster with custom database name (#33712) * `az postgres flexible-server upgrade`: Introduced `--validate-only` param for PVC (#33683) +* `az postgres flexible-server maintenance-event list`: Fix `TypeError` caused by an unsupported `--ids` argument (#33846) 2.88.0 ++++++ diff --git a/src/azure-cli/azure/cli/command_modules/postgresql/_params.py b/src/azure-cli/azure/cli/command_modules/postgresql/_params.py index b65320e55b4..4a39282ed8d 100644 --- a/src/azure-cli/azure/cli/command_modules/postgresql/_params.py +++ b/src/azure-cli/azure/cli/command_modules/postgresql/_params.py @@ -685,6 +685,7 @@ def _flexible_server_params(command_group): with self.argument_context('{} flexible-server maintenance-event list'.format(command_group)) as c: c.argument('maintenance_status', arg_type=maintenance_status_arg_type) + c.argument('server_name', id_part=None) c.ignore('ids') for scope in ['show', 'reschedule', 'apply-now']: diff --git a/src/azure-cli/azure/cli/command_modules/postgresql/tests/unit/test_maintenance_event_params.py b/src/azure-cli/azure/cli/command_modules/postgresql/tests/unit/test_maintenance_event_params.py new file mode 100644 index 00000000000..ec58e16a3b9 --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/postgresql/tests/unit/test_maintenance_event_params.py @@ -0,0 +1,30 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +import inspect +import unittest + +from azure.cli.command_modules.postgresql._params import load_arguments + + +class MaintenanceEventParamsTest(unittest.TestCase): + """Regression test for https://github.com/Azure/azure-cli/issues/33846. + + `az postgres flexible-server maintenance-event list` does not accept an `ids` + keyword argument in its custom command implementation, so the auto-generated + `--ids` argument must be ignored for that command. Otherwise, invoking the + command with `--ids` results in a TypeError. + """ + + def test_maintenance_event_list_ignores_ids(self): + source = inspect.getsource(load_arguments) + list_context_index = source.index("flexible-server maintenance-event list") + # the ignore('ids') call should immediately follow the list argument context + snippet = source[list_context_index:list_context_index + 300] + self.assertIn("c.ignore('ids')", snippet) + + +if __name__ == '__main__': + unittest.main() From 2ef713dab55662f4d604c59b25effdf9407101c9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 5 Aug 2026 02:20:54 +0000 Subject: [PATCH 3/4] Move test file from tests/unit/ to tests/latest/ for azdev discovery Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com> --- .../tests/{unit => latest}/test_maintenance_event_params.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/azure-cli/azure/cli/command_modules/postgresql/tests/{unit => latest}/test_maintenance_event_params.py (100%) diff --git a/src/azure-cli/azure/cli/command_modules/postgresql/tests/unit/test_maintenance_event_params.py b/src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_maintenance_event_params.py similarity index 100% rename from src/azure-cli/azure/cli/command_modules/postgresql/tests/unit/test_maintenance_event_params.py rename to src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_maintenance_event_params.py From 0cdd0301630ddd986448c131c6955b91074ae06e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 5 Aug 2026 03:15:28 +0000 Subject: [PATCH 4/4] fix: preserve server_name arg_type metadata and use runtime test for maintenance-event list Co-authored-by: a0x1ab <59631311+a0x1ab@users.noreply.github.com> --- .../cli/command_modules/postgresql/_params.py | 2 +- .../latest/test_maintenance_event_params.py | 40 +++++++++++++++---- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/azure-cli/azure/cli/command_modules/postgresql/_params.py b/src/azure-cli/azure/cli/command_modules/postgresql/_params.py index 4a39282ed8d..117daad37b2 100644 --- a/src/azure-cli/azure/cli/command_modules/postgresql/_params.py +++ b/src/azure-cli/azure/cli/command_modules/postgresql/_params.py @@ -685,7 +685,7 @@ def _flexible_server_params(command_group): with self.argument_context('{} flexible-server maintenance-event list'.format(command_group)) as c: c.argument('maintenance_status', arg_type=maintenance_status_arg_type) - c.argument('server_name', id_part=None) + c.argument('server_name', arg_type=server_name_resource_arg_type, id_part=None) c.ignore('ids') for scope in ['show', 'reschedule', 'apply-now']: diff --git a/src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_maintenance_event_params.py b/src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_maintenance_event_params.py index ec58e16a3b9..ba49abf8ae2 100644 --- a/src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_maintenance_event_params.py +++ b/src/azure-cli/azure/cli/command_modules/postgresql/tests/latest/test_maintenance_event_params.py @@ -3,10 +3,25 @@ # Licensed under the MIT License. See License.txt in the project root for license information. # -------------------------------------------------------------------------------------------- -import inspect import unittest +from unittest import mock -from azure.cli.command_modules.postgresql._params import load_arguments +from knack.arguments import IgnoreAction +from azure.cli.core.mock import DummyCli +from azure.cli.command_modules.postgresql import PostgreSQLCommandsLoader + + +def _load_command_and_arguments(command): + """Load the PostgreSQL command loader for *command* and return the loader.""" + cli = DummyCli(commands_loader_cls=PostgreSQLCommandsLoader) + loader = PostgreSQLCommandsLoader(cli) + cli.invocation = mock.MagicMock() + cli.invocation.commands_loader = loader + loader.command_name = command + loader.load_command_table(None) + loader.load_arguments(command) + loader._update_command_definitions() + return loader class MaintenanceEventParamsTest(unittest.TestCase): @@ -19,12 +34,23 @@ class MaintenanceEventParamsTest(unittest.TestCase): """ def test_maintenance_event_list_ignores_ids(self): - source = inspect.getsource(load_arguments) - list_context_index = source.index("flexible-server maintenance-event list") - # the ignore('ids') call should immediately follow the list argument context - snippet = source[list_context_index:list_context_index + 300] - self.assertIn("c.ignore('ids')", snippet) + """The ``ids`` argument for the list command must use IgnoreAction.""" + loader = _load_command_and_arguments( + 'postgres flexible-server maintenance-event list' + ) + ids_arg = loader.argument_registry.arguments.get( + 'postgres flexible-server maintenance-event list', {} + ).get('ids') + self.assertIsNotNone(ids_arg, "'ids' argument not found in argument registry") + action = ids_arg.settings.get('action') + self.assertIs( + action, + IgnoreAction, + "Expected 'ids' to be registered with IgnoreAction (via c.ignore('ids')), " + "but got: {}".format(action), + ) if __name__ == '__main__': unittest.main() +