{"record":{"id":"07b42275a74e65f1","repo":"langchain-ai/deepagents","slug":"argv-must-be-a-non-empty-list-of-strings-when-prov","errorCode":null,"errorMessage":"argv must be a non-empty list of strings when provided.","messagePattern":"argv must be a non-empty list of strings when provided\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"libs/code/deepagents_code/hooks/models/config.py","lineNumber":48,"sourceCode":"    `argv` is a temporary legacy-migration compatibility field. Remove it with\n    `hooks.legacy` and `hooks.migration` after September 1, 2026.\n    \"\"\"\n\n    type: Literal[\"command\"]\n    command: str\n    argv: list[str] | None = None\n    timeout: float | None = Field(default=None, gt=0, allow_inf_nan=False)\n    status_message: str | None = Field(default=None, alias=\"statusMessage\")\n    async_: bool | None = Field(default=None, alias=\"async\")\n\n    @field_validator(\"argv\", mode=\"after\")\n    @classmethod\n    def _normalize_argv(cls, value: list[str] | None) -> list[str] | None:\n        if value is None:\n            return None\n        if not value or not all(isinstance(part, str) for part in value):\n            msg = \"argv must be a non-empty list of strings when provided.\"\n            raise ValueError(msg)\n        if not value[0].strip():\n            msg = \"argv[0] must be a non-empty executable path.\"\n            raise ValueError(msg)\n        return value\n\n    @field_validator(\"async_\", mode=\"after\")\n    @classmethod\n    def _normalize_async(cls, value: bool | None) -> None:\n        if value:\n            msg = \"async command hooks are not yet supported.\"\n            raise ValueError(msg)\n\n\n# Extension point for future handler kinds, kept as a plain assignment rather\n# than a `type` alias: a `type` alias becomes the schema identity and renames\n# the generated `$defs` entry from `CommandHandlerSpec` to `HandlerSpec`.\nHandlerSpec = CommandHandlerSpec\n","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/langchain-ai/deepagents/blob/a1af029e6e73cb17c36bff823d227747b28e91e1/libs/code/deepagents_code/hooks/models/config.py#L30-L66","documentation":"`_normalize_argv` is a pydantic field validator on the command hook handler spec in `libs/code/deepagents_code/hooks/models/config.py`. It rejects any `argv` that is provided but is either an empty list or contains non-string elements. The library requires a well-formed command vector so it can spawn the hook process safely.","triggerScenarios":"Defining a command hook in hook config where `argv` is explicitly given as `[]`, or as a list containing non-strings (e.g. `[\"echo\", 42]`, `[None]`, or nested lists), when the config model is validated by pydantic.","commonSituations":"Hand-edited hook config files (JSON/TOML/YAML) where numbers or booleans sneak into argv; programmatic config construction that passes an empty list as a placeholder; deserializing config where argv items were parsed as ints.","solutions":["Ensure every element of `argv` is a string, coercing numbers/paths with `str(...)` before assignment","Provide at least one element — put the executable path in `argv[0]`","If the hook should have no command, omit the `argv` key (or pass None) instead of `[]`"],"exampleFix":"// before\nhandler = CommandHandlerSpec(argv=[\"python\", 3])\n// after\nhandler = CommandHandlerSpec(argv=[\"python\", \"-m\", \"mypkg.hooks\"])","handlingStrategy":"validation","validationCode":"def valid_argv(argv):\n    return argv is None or (isinstance(argv, list) and len(argv) > 0 and all(isinstance(p, str) for p in argv))\n\nif not valid_argv(cfg.get(\"argv\")):\n    raise ValueError(\"argv must be a non-empty list of strings\")","typeGuard":"def is_str_list(v: object) -> TypeGuard[list[str]]:\n    return isinstance(v, list) and all(isinstance(x, str) for x in v)","tryCatchPattern":"try:\n    spec = CommandHandlerSpec(**cfg)\nexcept ValueError as e:\n    logger.error(\"invalid hook config: %s\", e)\n    raise SystemExit(1) from e","preventionTips":["Coerce config values to strings before building the spec","Never pass an empty list as a placeholder — omit the key instead","Validate hook config files with the pydantic model at load time"],"tags":["validation","pydantic","config","hooks"],"backgroundTag":"schema-validation-failed","analyzedSha":"a1af029e6e73cb17c36bff823d227747b28e91e1","analyzedAt":"2026-08-29T11:43:24.718Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}