{"record":{"id":"2e963c40dfb1a24b","repo":"OpenBB-finance/OpenBB","slug":"argument-name-cannot-be-empty","errorCode":null,"errorMessage":"Argument name cannot be empty","messagePattern":"Argument name cannot be empty","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"openbb_platform/extensions/mcp_server/openbb_mcp_server/models/mcp_config.py","lineNumber":55,"sourceCode":"\nclass ArgumentDefinitionModel(BaseModel):\n    \"\"\"Model for validating prompt argument definitions.\"\"\"\n\n    name: str = Field(..., description=\"Name of the argument\")\n    type: str = Field(default=\"str\", description=\"Type of the argument\")\n    default: Any | None = Field(\n        default=None, description=\"Default value for the argument\"\n    )\n    description: str | None = Field(\n        default=None, description=\"Description of the argument\"\n    )\n\n    @field_validator(\"name\")\n    @classmethod\n    def validate_name(cls, v: str) -> str:\n        \"\"\"Validate argument name is a valid identifier.\"\"\"\n        if not v:\n            raise ValueError(\"Argument name cannot be empty\")\n        if not re.match(r\"^[a-zA-Z_][a-zA-Z0-9_]*$\", v):\n            raise ValueError(f\"Argument name '{v}' must be a valid Python identifier\")\n        return v\n\n    @field_validator(\"type\")\n    @classmethod\n    def validate_type(cls, v: str) -> str:\n        \"\"\"Validate type is a recognized type string.\"\"\"\n        valid_types = {\n            \"str\",\n            \"string\",\n            \"int\",\n            \"integer\",\n            \"float\",\n            \"bool\",\n            \"boolean\",\n            \"list\",\n            \"dict\",","sourceCodeStart":37,"sourceCodeEnd":73,"githubUrl":"https://github.com/OpenBB-finance/OpenBB/blob/3e071fcc2cd9f891cac6040ae60296dba76dab46/openbb_platform/extensions/mcp_server/openbb_mcp_server/models/mcp_config.py#L37-L73","documentation":"Pydantic field_validator error on ArgumentDefinitionModel: the 'name' field of an MCP prompt/tool argument definition was given an empty string. Argument names become template placeholders and keyword parameters, so an empty name is structurally invalid and is rejected at config-parse time before anything is constructed.","triggerScenarios":"Loading an MCP config (YAML/JSON) where an argument entry has name: \"\" or name: null serialized as empty; programmatically generating argument definitions with a missing-name bug; templates that default name to an empty string.","commonSituations":"Hand-written MCP prompt configs with placeholder arguments; config generators iterating empty lists; YAML indentation putting the name key on the wrong node.","solutions":["Give every argument a non-empty name in the config file.","Audit the arguments: list in your prompt config for empty entries and remove or fill them.","If generating configs in code, assert name truthiness before building the model."],"exampleFix":"# before (config.yaml)\narguments:\n  - name: \"\"\n    type: str\n\n# after\narguments:\n  - name: symbol\n    type: str","handlingStrategy":"validation","validationCode":"def validate_arguments(args: list[dict]) -> None:\n    for a in args:\n        if not a.get(\"name\"):\n            raise ValueError(f\"argument with empty name: {a}\")","typeGuard":"import re\n\ndef has_valid_argument_names(args: list[dict]) -> bool:\n    return all(isinstance(a.get(\"name\"), str) and re.match(r\"^[a-zA-Z_][a-zA-Z0-9_]*$\", a[\"name\"]) for a in args)","tryCatchPattern":null,"preventionTips":["Lint MCP config files with a schema that requires non-empty argument names.","In generators, skip emitting argument entries whose name is falsy.","Test configs by loading MCPConfigModel before deploying."],"tags":["openbb","mcp","pydantic","config-validation"],"backgroundTag":null,"analyzedSha":"3e071fcc2cd9f891cac6040ae60296dba76dab46","analyzedAt":"2026-08-14T23:40:48.960Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}