{"record":{"id":"631123cd5417c835","repo":"langchain-ai/deepagents","slug":"field-name-entries-must-be-non-empty-non-whit","errorCode":null,"errorMessage":"`{field_name}` entries must be non-empty, non-whitespace strings","messagePattern":"`(.+?)` entries must be non-empty, non-whitespace strings","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/deepagents/deepagents/profiles/harness/harness_profiles.py","lineNumber":899,"sourceCode":"\n    Scaffolding-class/name rejection and matched-something coverage are\n    deliberately NOT checked here — those need the fully assembled middleware\n    stack.\n\n    Args:\n        entry: Candidate entry. Must be a string to pass.\n        field_name: Field being validated, used for error messages.\n\n    Raises:\n        TypeError: If `entry` is not a string.\n        ValueError: If `entry` violates any of the grammar rules above.\n    \"\"\"\n    if not isinstance(entry, str):\n        msg = f\"`{field_name}` entries must be strings, got {type(entry).__name__} ({entry!r})\"\n        raise TypeError(msg)\n    if not entry or entry.isspace():\n        msg = f\"`{field_name}` entries must be non-empty, non-whitespace strings\"\n        raise ValueError(msg)\n    if \":\" in entry:\n        msg = (\n            f\"`{field_name}` entries must be plain middleware names; class-path (`module:Class`) entries are not currently supported, got {entry!r}.\"\n        )\n        raise ValueError(msg)\n    if entry.startswith(\"_\"):\n        msg = (\n            f\"`{field_name}` entry {entry!r} cannot start with '_' \"\n            f\"(underscore-prefixed names refer to private middleware classes \"\n            f\"not part of the public exclusion surface).\"\n        )\n        raise ValueError(msg)\n\n\ndef _serialize_runtime_excluded_middleware_entry(\n    entry: type[AgentMiddleware] | str,\n) -> str:\n    \"\"\"Serialize a runtime `excluded_middleware` entry back to config form.","sourceCodeStart":881,"sourceCodeEnd":917,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/deepagents/deepagents/profiles/harness/harness_profiles.py#L881-L917","documentation":"HarnessProfileConfig middleware-list validation rejects entries that are empty or whitespace-only strings. The library requires every configured middleware name to be a usable identifier so exclusion lookups against the middleware registry are unambiguous. This is raised eagerly in `__post_init__` so bad configs fail at construction time rather than at agent creation.","triggerScenarios":"Constructing or deserializing a HarnessProfileConfig (e.g. via `HarnessProfileConfig(**data)` or loading YAML/JSON config) with an `excluded_middleware` (or similar middleware string list) containing `\"\"`, `\" \"`, or `\"\\t\"`.","commonSituations":"Hand-edited config files with trailing comma leaving a blank item; template placeholders never filled in; programmatic list building that appends empty strings from splitting `\"a,,b\"`; env-var-driven config where the var is set to whitespace.","solutions":["Remove the empty/whitespace entry from the middleware list in your config","If the value comes from an env var or split string, filter out blanks before constructing the config: `[e for e in raw.split(',') if e.strip()]`","Fix the source config file (YAML/JSON) to omit the item entirely instead of supplying an empty string"],"exampleFix":"# before\nconfig = HarnessProfileConfig(excluded_middleware=[\"websearch\", \"\"])\n# after\nconfig = HarnessProfileConfig(excluded_middleware=[\"websearch\"])","handlingStrategy":"validation","validationCode":"names = cfg.get(\"excluded_middleware\", [])\nbad = [n for n in names if not isinstance(n, str) or not n.strip()]\nif bad:\n    raise ValueError(f\"blank middleware entries: {bad!r}\")","typeGuard":"def is_valid_middleware_name(entry: object) -> TypeGuard[str]:\n    return isinstance(entry, str) and bool(entry) and not entry.isspace()","tryCatchPattern":"try:\n    config = HarnessProfileConfig(**raw)\nexcept ValueError as e:\n    if \"non-empty, non-whitespace\" in str(e):\n        raw[\"excluded_middleware\"] = [n for n in raw.get(\"excluded_middleware\", []) if isinstance(n, str) and n.strip()]\n        config = HarnessProfileConfig(**raw)\n    else:\n        raise","preventionTips":["Filter empty strings immediately after splitting comma-separated config values","Validate config files in CI with a schema check on middleware lists","Never build lists with `raw.split(',')` without stripping and dropping blanks"],"tags":["config","validation","middleware"],"backgroundTag":"invalid-config-value","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}