p-e-w/heretic · error · ValueError
whitespace is not allowed
Error message
whitespace is not allowed
What it means
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.
Source
Thrown at src/heretic/config.py:140
"Optional name to distinguish multiple instances of the same plugin class. "
"Instance-specific settings live under `[scorer.<ClassName>_<instance_name>]`."
),
)
@field_validator("instance_name")
@classmethod
def validate_instance_name(cls, value: str | None) -> str | None:
if value is None:
return value
if not value.strip():
raise ValueError("cannot be empty or whitespace")
if "." in value:
raise ValueError("'.' is not allowed")
if any(char.isspace() for char in value):
raise ValueError("whitespace is not allowed")
return value
class BenchmarkSpecification(BaseModel):
task: str = Field(
description="Task ID of the benchmark in the Language Model Evaluation Harness."
)
name: str = Field(description="Name of the benchmark for presentation purposes.")
description: str = Field(
description="Description of the benchmark for presentation purposes."
)
class Settings(BaseSettings):
model: str = Field(description="Hugging Face model ID, or path to model on disk.")View on GitHub (pinned to bedb94ef11)
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
Example fix
// before instance_name = "my scorer" // after instance_name = "my-scorer"
Defensive patterns
Strategy: validation
Validate before calling
if any(c.isspace() for c in (instance_name or "")):
raise ValueError("instance_name must not contain whitespace") Type guard
def is_whitespace_free(name: str) -> bool:
return isinstance(name, str) and name.strip() == name and not any(c.isspace() for c in name) Try / catch
try:
cfg.validate_instance_name(name)
except ValueError:
name = "-".join(name.split()) Prevention
- Quote shell arguments; avoid free-text names
- Normalize names with slugify or "-".join(s.split())
- Reject whitespace in your own config loader early
When it happens
Trigger: Calling validate_instance_name with values like "my scorer", "scorer\t1", or "name\n" — often from free-text config values or unquoted shell arguments.
Common situations: Multi-word names in config.toml, CLI args passed unquoted ("--instance-name my scorer"), or names read from files with trailing newlines.
Related errors
- '.' is not allowed
- cannot be empty or whitespace
- Duplicate scorer instance name: {scorer_key}. Give each inst
- No scorers configured. Set 'scorers' in config.toml
- prompts must not be empty
AI-assisted analysis of p-e-w/heretic@bedb94ef11 (2026-08-29).
Data as JSON: /api/errors/a6f8df672856db19.
Report an issue: GitHub.