mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Validate workflow invocation parameters values are dicts
The `parameters` field in workflow invocation payloads expects values
to be dicts mapping parameter names to values, but this was not
enforced by the schema. Passing scalar values (e.g. `{"1": 70}`)
caused a TypeError in `_step_parameters` when calling `dict.update()`
on a non-dict value.
Tighten the Pydantic type from `dict[str, Any]` to
`dict[str, dict[str, Any]]` so invalid payloads are rejected with a
400 instead of causing a 500.
Fixes https://github.com/galaxyproject/galaxy/issues/22387
This commit is contained in:
@@ -17056,7 +17056,9 @@ export interface components {
|
||||
* @default {}
|
||||
*/
|
||||
parameters: {
|
||||
[key: string]: unknown;
|
||||
[key: string]: {
|
||||
[key: string]: unknown;
|
||||
};
|
||||
} | null;
|
||||
/**
|
||||
* Legacy Step Parameters Normalized
|
||||
|
||||
@@ -178,7 +178,7 @@ class InvokeWorkflowPayload(GetTargetHistoryPayload):
|
||||
return json.loads(v)
|
||||
return v
|
||||
|
||||
parameters: Optional[dict[str, Any]] = Field(
|
||||
parameters: Optional[dict[str, dict[str, Any]]] = Field(
|
||||
{},
|
||||
title=STEP_PARAMETERS_TITLE,
|
||||
description=STEP_PARAMETERS_DESCRIPTION,
|
||||
|
||||
@@ -28,6 +28,7 @@ from galaxy.exceptions import error_codes
|
||||
from galaxy.tool_util_models import UserToolSource
|
||||
from galaxy.util import UNKNOWN
|
||||
from galaxy_test.base import rules_test_data
|
||||
from galaxy_test.base.api_asserts import assert_error_message_contains
|
||||
from galaxy_test.base.populators import (
|
||||
DatasetCollectionPopulator,
|
||||
DatasetPopulator,
|
||||
@@ -8231,6 +8232,14 @@ steps:
|
||||
self.__assert_lines_hid_line_count_is(history_id, 2, 5)
|
||||
self.__assert_lines_hid_line_count_is(history_id, 3, 5)
|
||||
|
||||
@skip_without_tool("random_lines1")
|
||||
def test_run_replace_params_by_tool_rejects_scalar_values(self):
|
||||
workflow_request, history_id, workflow_id = self._setup_random_x2_workflow("test_for_reject_scalar_params")
|
||||
workflow_request["parameters"] = dumps(dict(random_lines1=5))
|
||||
response = self.workflow_populator.invoke_workflow_raw(workflow_id, workflow_request)
|
||||
self._assert_status_code_is(response, 400)
|
||||
assert_error_message_contains(response, "Input should be a valid dictionary")
|
||||
|
||||
@skip_without_tool("random_lines1")
|
||||
def test_run_replace_params_by_uuid(self):
|
||||
workflow_request, history_id, workflow_id = self._setup_random_x2_workflow("test_for_replace_")
|
||||
|
||||
Reference in New Issue
Block a user