{"record":{"id":"2b1326e293dc96ca","repo":"p-e-w/heretic","slug":"cannot-be-empty-or-whitespace","errorCode":null,"errorMessage":"cannot be empty or whitespace","messagePattern":"cannot be empty or whitespace","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/heretic/config.py","lineNumber":134,"sourceCode":"        ),\n    )\n\n    instance_name: str | None = Field(\n        default=None,\n        description=(\n            \"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(","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/p-e-w/heretic/blob/bedb94ef117a271532ac2058447fbc165d5051bd/src/heretic/config.py#L116-L152","documentation":"validate_instance_name rejects instance names that are empty or contain only whitespace characters. The library requires every scorer/instance name to be a non-empty, meaningful identifier so generated keys are unambiguous. It fails fast at config-validation time rather than producing broken instance keys later.","triggerScenarios":"Calling HereticConfig.validate_instance_name with an empty string (\"\") or a string of only spaces/tabs (e.g. \"   \"), typically via instance_name parsed from config.toml or CLI where the value was left blank.","commonSituations":"An unset-but-present `instance_name = \"\"` in config.toml, shell variable interpolation producing an empty value (`instance_name=\"$MY_VAR\"` with MY_VAR unset), or copy-pasting a name with only spaces.","solutions":["Set a non-empty instance_name in config.toml or the API call (e.g. instance_name = \"scorer-a\")","If the name is optional, omit the field entirely (pass None) instead of an empty string","Trim upstream input and skip/None-out empty values before validation"],"exampleFix":"// before\ninstance_name = \"\"\n// after\ninstance_name = \"scorer-a\"","handlingStrategy":"validation","validationCode":"if instance_name is not None and not instance_name.strip():\n    raise ValueError(\"instance_name must not be empty or whitespace\")","typeGuard":"def is_valid_instance_name(v: str | None) -> bool:\n    return v is None or (bool(v.strip()) and \".\" not in v and not any(c.isspace() for c in v))","tryCatchPattern":"try:\n    cfg.validate_instance_name(raw_name)\nexcept ValueError as e:\n    logger.error(\"Invalid instance_name: %s\", e)\n    raw_name = None  # fall back to default","preventionTips":["Omit instance_name rather than passing \"\"","Strip and normalize user input before validation","Add a config lint step that checks instance names"],"tags":["config","validation","python"],"backgroundTag":"empty-value-validation","analyzedSha":"bedb94ef117a271532ac2058447fbc165d5051bd","analyzedAt":"2026-08-29T08:38:06.692Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}