{"record":{"id":"a6f8df672856db19","repo":"p-e-w/heretic","slug":"whitespace-is-not-allowed","errorCode":null,"errorMessage":"whitespace is not allowed","messagePattern":"whitespace is not allowed","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/heretic/config.py","lineNumber":140,"sourceCode":"            \"Optional name to distinguish multiple instances of the same plugin class. \"\n            \"Instance-specific settings live under `[scorer.<ClassName>_<instance_name>]`.\"\n        ),\n    )\n\n    @field_validator(\"instance_name\")\n    @classmethod\n    def validate_instance_name(cls, value: str | None) -> str | None:\n        if value is None:\n            return value\n\n        if not value.strip():\n            raise ValueError(\"cannot be empty or whitespace\")\n\n        if \".\" in value:\n            raise ValueError(\"'.' is not allowed\")\n\n        if any(char.isspace() for char in value):\n            raise ValueError(\"whitespace is not allowed\")\n\n        return value\n\n\nclass BenchmarkSpecification(BaseModel):\n    task: str = Field(\n        description=\"Task ID of the benchmark in the Language Model Evaluation Harness.\"\n    )\n\n    name: str = Field(description=\"Name of the benchmark for presentation purposes.\")\n\n    description: str = Field(\n        description=\"Description of the benchmark for presentation purposes.\"\n    )\n\n\nclass Settings(BaseSettings):\n    model: str = Field(description=\"Hugging Face model ID, or path to model on disk.\")","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/p-e-w/heretic/blob/bedb94ef117a271532ac2058447fbc165d5051bd/src/heretic/config.py#L122-L158","documentation":"validate_instance_name rejects any string containing whitespace characters (spaces, tabs, newlines). Instance names become parts of scorer keys, so whitespace would break key formatting and lookups.","triggerScenarios":"Calling validate_instance_name with values like \"my scorer\", \"scorer\\t1\", or \"name\\n\" — often from free-text config values or unquoted shell arguments.","commonSituations":"Multi-word names in config.toml, CLI args passed unquoted (\"--instance-name my scorer\"), or names read from files with trailing newlines.","solutions":["Remove whitespace: use hyphens or underscores (\"my-scorer\", \"my_scorer\")","Strip and normalize input: \"-\".join(value.split()) before validation","Quote CLI arguments and use single-token names"],"exampleFix":"// before\ninstance_name = \"my scorer\"\n// after\ninstance_name = \"my-scorer\"","handlingStrategy":"validation","validationCode":"if any(c.isspace() for c in (instance_name or \"\")):\n    raise ValueError(\"instance_name must not contain whitespace\")","typeGuard":"def is_whitespace_free(name: str) -> bool:\n    return isinstance(name, str) and name.strip() == name and not any(c.isspace() for c in name)","tryCatchPattern":"try:\n    cfg.validate_instance_name(name)\nexcept ValueError:\n    name = \"-\".join(name.split())","preventionTips":["Quote shell arguments; avoid free-text names","Normalize names with slugify or \"-\".join(s.split())","Reject whitespace in your own config loader early"],"tags":["config","validation","naming"],"backgroundTag":"invalid-identifier-name","analyzedSha":"bedb94ef117a271532ac2058447fbc165d5051bd","analyzedAt":"2026-08-29T08:38:06.692Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}