Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,12 @@ def patch_connection(
status.HTTP_404_NOT_FOUND, f"The Connection with connection_id: `{connection_id}` was not found"
)

fields_to_update = patch_body.model_fields_set
if update_mask:
fields_to_update = fields_to_update.intersection(update_mask)

try:
ConnectionBody(**patch_body.model_dump())
ConnectionBody(**patch_body.model_dump(include=fields_to_update))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As evidenced bythe CI failures, it looks like you are validating only the subset of fields being updated against the full ConnectionBody model. Since ConnectionBody has required fields (e.g. conn_type), partial patch payloads now fail validation.

I think we may need to retrieve the existing model, merge the patch data, and then validate the merged result instead.

except ValidationError as e:
raise RequestValidationError(errors=e.errors())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,11 @@ def patch_dag(
status.HTTP_400_BAD_REQUEST, "Only `is_paused` field can be updated through the REST API"
)
fields_to_update = fields_to_update.intersection(update_mask)
else:
try:
DAGPatchBody(**patch_body.model_dump())
except ValidationError as e:
raise RequestValidationError(errors=e.errors())

try:
DAGPatchBody(**patch_body.model_dump(include=fields_to_update))
except ValidationError as e:
raise RequestValidationError(errors=e.errors())

data = patch_body.model_dump(include=fields_to_update, by_alias=True)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,15 @@ def update_orm_from_pydantic(
status.HTTP_404_NOT_FOUND, f"The Variable with key: `{variable_key}` was not found"
)

non_update_fields = {"key"}
fields_to_update = patch_body.model_fields_set
if update_mask:
fields_to_update = fields_to_update.intersection(update_mask)

try:
VariableBody(**patch_body.model_dump())
VariableBody(**patch_body.model_dump(include=fields_to_update))
except ValidationError as e:
raise RequestValidationError(errors=e.errors())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Above comment applies here as well.

non_update_fields = {"key"}

if patch_body.key != old_variable.key:
raise HTTPException(
Expand Down
Loading