From 19725d546d23d7d6c398083f017d4894ced54c3b Mon Sep 17 00:00:00 2001 From: NopeCharon <115794254+NopeCharon@users.noreply.github.com> Date: Sun, 1 Nov 2026 15:26:41 +0530 Subject: [PATCH] Require --name when updating metadata instances 'elyra-metadata update' needs the name of the instance to update, but the CLI declared '--name' as optional, as it is for 'create', where the name can be derived from the display name. When the option was missing, the metadata service rejected the request and the CLI reported an unexpected exception: The following exception occurred saving metadata instance for schema 'runtime-image': The 'name' parameter requires a value. Declare '--name' as required for 'update', so the CLI reports the missing parameter and displays the usage, like it does for other required parameters: ERROR: '--name' is a required parameter. Fixes #2577 Signed-off-by: NopeCharon <115794254+NopeCharon@users.noreply.github.com> --- elyra/metadata/metadata_app.py | 6 ++++++ elyra/tests/metadata/test_metadata_app.py | 18 ++++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/elyra/metadata/metadata_app.py b/elyra/metadata/metadata_app.py index a65c89d17..55219c94f 100644 --- a/elyra/metadata/metadata_app.py +++ b/elyra/metadata/metadata_app.py @@ -383,6 +383,12 @@ def print_help(self): class SchemaspaceUpdate(SchemaspaceCreate): """Handles the 'update' subcommand functionality for a specific schemaspace.""" + # Unlike on create, the name can't be derived from the display name since it identifies + # the existing instance. + name_option = CliOption( + "--name", name="name", description="The name of the metadata instance to update.", required=True + ) + update_mode = True diff --git a/elyra/tests/metadata/test_metadata_app.py b/elyra/tests/metadata/test_metadata_app.py index 3a784b50d..ab14ceccf 100644 --- a/elyra/tests/metadata/test_metadata_app.py +++ b/elyra/tests/metadata/test_metadata_app.py @@ -392,10 +392,8 @@ def test_update_no_schema_single(script_runner, mock_data_dir): # Note: this test will break if it ever supports multiple. ret = script_runner.run("elyra-metadata", "update", "runtime-images") assert ret.success is False - assert ( - "The following exception occurred saving metadata instance for schema 'runtime-image': " - "The 'name' parameter requires a value." in ret.stdout - ) + assert "ERROR: '--name' is a required parameter." in ret.stdout + assert "The following exception occurred" not in ret.stdout def test_update_no_schema_multiple(script_runner, mock_data_dir): @@ -418,10 +416,18 @@ def test_update_bad_schema_multiple(script_runner, mock_data_dir): def test_update_no_name(script_runner, mock_data_dir): ret = script_runner.run("elyra-metadata", "update", METADATA_TEST_SCHEMASPACE, "--schema_name=metadata-test") assert ret.success is False + assert "ERROR: '--name' is a required parameter." in ret.stdout assert ( - "The following exception occurred saving metadata instance for schema 'metadata-test': " - "The 'name' parameter requires a value." in ret.stdout + "--name= (Required. Format: sequence of characters) \n\tThe name of the metadata instance to update." + in ret.stdout ) + assert "The following exception occurred" not in ret.stdout + + ret = script_runner.run( + "elyra-metadata", "update", METADATA_TEST_SCHEMASPACE, "--schema_name=metadata-test", "--name=" + ) + assert ret.success is False + assert "ERROR: Parameter '--name' requires a value." in ret.stdout def test_update_no_instance(script_runner, mock_data_dir):