Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add data field to returned object on flowheader if flow is a component #5373

Merged
merged 4 commits into from
Dec 23, 2024
Merged
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
19 changes: 14 additions & 5 deletions src/backend/base/langflow/services/database/models/flow/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
from emoji import purely_emoji
from fastapi import HTTPException, status
from loguru import logger
from pydantic import BaseModel, field_serializer, field_validator, model_validator
from pydantic import (
BaseModel,
ValidationInfo,
field_serializer,
field_validator,
)
from sqlalchemy import Text, UniqueConstraint
from sqlmodel import JSON, Column, Field, Relationship, SQLModel

Expand Down Expand Up @@ -203,16 +208,20 @@ class FlowHeader(BaseModel):
id: UUID = Field(description="Unique identifier for the flow")
name: str = Field(description="The name of the flow")
folder_id: UUID | None = Field(
None, description="The ID of the folder containing the flow. None if not associated with a folder"
None,
description="The ID of the folder containing the flow. None if not associated with a folder",
)
is_component: bool | None = Field(None, description="Flag indicating whether the flow is a component")
endpoint_name: str | None = Field(None, description="The name of the endpoint associated with this flow")
description: str | None = Field(None, description="A description of the flow")
data: dict | None = Field(None, description="The data of the component, if is_component is True")

@model_validator(mode="before")
@field_validator("data", mode="before")
@classmethod
def validate_flow_header(cls, data: dict):
return data
def validate_flow_header(cls, value: dict, info: ValidationInfo):
if not info.data["is_component"]:
return None
return value


class FlowUpdate(SQLModel):
Expand Down
Loading