langflow-ai/langflow · error · ValueError
String must not be empty.
Error message
String must not be empty.
What it means
Pydantic AfterValidator on NonEmptyString (used for fields like tool ids in the wxO API payload schemas): a string that survives stripping but is empty, or becomes empty after strip, fails with 'String must not be empty.' The enclosing request model is part of provider_data validation on deployment create/update, so FastAPI surfaces this as a 422 with this message inside the validation errors.
Source
Thrown at src/backend/base/langflow/api/v1/mappers/deployments/watsonx_orchestrate/payloads.py:41
if TYPE_CHECKING:
from langflow.api.v1.schemas.deployments import DeploymentCreateRequest
# Keep API-boundary scalar normalization local to this module instead of
# importing adapter-layer aliases, so mapper contracts can evolve independently.
NormalizedStr = Annotated[
str,
StringConstraints(
strip_whitespace=True,
min_length=1,
),
]
def _validate_non_empty_string(value: str) -> str:
if not value.strip():
msg = "String must not be empty."
raise ValueError(msg)
return value
NonEmptyString = Annotated[str, AfterValidator(_validate_non_empty_string)]
class WatsonxApiProviderAccountCreate(BaseModel):
"""WXO provider-account provider_data contract at API boundary.
This schema is owned by the WXO mapper and parsed once to validate the
provider-account provider_data payload before URL policy checks, credential
verification payload shaping, and DB field extraction.
"""
model_config = {"extra": "forbid"}
url: ValidatedUrl
tenant_id: Annotated[str | None, StringConstraints(strip_whitespace=True, min_length=1)] = NoneView on GitHub (pinned to 976ec789d2)
Solutions
- Send a real non-blank value for the field, or omit the field/item entirely if it is optional.
- Trim client-side before sending: skip list entries whose value strips to empty.
- If generating payloads from templates, guard interpolated ids with a falsy check so empty variables drop the key.
Example fix
// before
{"upsert_tools": [{"tool_id": " ", "add_app_ids": []}]}
// after
{"upsert_tools": [{"tool_id": "my-tool-id", "add_app_ids": []}]} Defensive patterns
Strategy: validation
Validate before calling
def clean_non_empty(v: str | None) -> str | None:
if v is None:
return None
v = v.strip()
return v or None # drop blank instead of sending it
payload = {k: clean_non_empty(v) for k, v in raw.items() if clean_non_empty(v) is not None} Type guard
const isNonEmptyString = (v: unknown): v is string => typeof v === "string" && v.trim().length > 0;
Try / catch
try {
await api.post("/deployments", body);
} catch (e) {
if (e.response?.status === 422 && JSON.stringify(e.response.data).includes("String must not be empty")) {
showFieldError("Blank values are not allowed; fill or remove the field.");
}
} Prevention
- Strip and drop blank strings client-side before serialization.
- Skip optional list entries whose identifier is blank instead of submitting them.
- Prefer omitting optional keys over sending empty strings.
When it happens
Trigger: POST/PATCH a wxO deployment with provider_data containing a whitespace-only or empty string where a NonEmptyString field is expected — e.g. upsert_tools[].tool_id = "" or " ", or a remove_tools entry that is blank.
Common situations: Programmatic request builders defaulting ids to empty strings instead of omitting the field; template/Jinja-generated payloads inserting blank variables; UI form submitting an untouched input.
Related errors
- credentials contains duplicate key values: {sorted(duplicate
- {label} must not reference connections app_ids: {invalid_raw
- {label} add_app_ids and remove_app_ids must not overlap: {ov
- {remove_label} cannot be combined with upsert for the same i
- connections contains app_id values not referenced by operati
AI-assisted analysis of langflow-ai/langflow@976ec789d2 (2026-08-14).
Data as JSON: /api/errors/906748b4e0496d36.
Report an issue: GitHub.