Skip to content

Commit b6e3f88

Browse files
committed
Run landing request state through validator
1 parent c3390f7 commit b6e3f88

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

lib/galaxy/managers/landing.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
)
55
from uuid import uuid4
66

7-
from pydantic import UUID4
7+
from pydantic import (
8+
UUID4,
9+
ValidationError,
10+
)
811
from sqlalchemy import select
912

1013
from galaxy.exceptions import (
@@ -30,6 +33,7 @@
3033
)
3134
from galaxy.security.idencoding import IdEncodingHelper
3235
from galaxy.structured_app import StructuredApp
36+
from galaxy.tool_util_models.parameters import DataOrCollectionRequestAdapter
3337
from galaxy.util import safe_str_cmp
3438
from .context import ProvidesUserContext
3539

@@ -73,11 +77,25 @@ def create_workflow_landing_request(self, payload: CreateWorkflowLandingRequestP
7377
model.workflow_source = payload.workflow_id
7478
model.uuid = uuid4()
7579
model.client_secret = payload.client_secret
76-
model.request_state = payload.request_state
80+
model.request_state = self.validate_workflow_request_state(payload.request_state)
7781
model.public = payload.public
7882
self._save(model)
7983
return self._workflow_response(model)
8084

85+
def validate_workflow_request_state(self, request_state: Optional[dict]) -> Optional[dict]:
86+
# This would ideally be run in the context of a workflow input definition
87+
if isinstance(request_state, dict):
88+
for key, value in request_state.items():
89+
if isinstance(value, dict):
90+
try:
91+
# persist values after model validators and aliases have been applied
92+
request_state[key] = DataOrCollectionRequestAdapter.validate_python(value).model_dump(
93+
by_alias=True, exclude_unset=True, mode="json"
94+
)
95+
except ValidationError:
96+
pass
97+
return request_state
98+
8199
def claim_tool_landing_request(
82100
self, trans: ProvidesUserContext, uuid: UUID4, claim: Optional[ClaimLandingPayload]
83101
) -> ToolLandingRequest:

0 commit comments

Comments
 (0)