affaan-m/ECC · error · ValueError
Template name must be a non-empty string
Error message
Template name must be a non-empty string
What it means
_validate_template_input() guards register_template() and deregister_template(). If the name argument is not a string or is empty/whitespace-only, this ValueError fires before the registry is touched. It rejects None, non-string types, '', and ' '.
Source
Thrown at src/llm/prompt/templates/__init__.py:12
"""Provider-specific prompt template helpers."""
from __future__ import annotations
_TEMPLATE_REGISTRY: dict[str, str] = {}
TEMPLATES = _TEMPLATE_REGISTRY
def _validate_template_input(name: str, template: str | None = None) -> None:
"""Validate template registry inputs before mutating the registry."""
if not isinstance(name, str) or not name.strip():
raise ValueError("Template name must be a non-empty string")
if template is not None and (not isinstance(template, str) or not template.strip()):
raise ValueError("Template content must be a non-empty string")
def register_template(name: str, template: str) -> None:
"""Register or replace a named prompt template."""
_validate_template_input(name, template)
_TEMPLATE_REGISTRY[name] = template
def deregister_template(name: str) -> None:
"""Remove a named prompt template if it is registered."""
_validate_template_input(name)
_TEMPLATE_REGISTRY.pop(name, None)
def clear_templates() -> None:
"""Remove all registered prompt templates."""View on GitHub (pinned to 01e15490f0)
Solutions
- Ensure the name is a non-empty, stripped string before calling register_template/deregister_template.
- Skip registration when the computed name is falsy rather than passing it through.
- Add a unit test that asserts the validation message for '' and None.
Example fix
# before
name = config.get('template_name') # may be None
register_template(name, content)
# after
name = (config.get('template_name') or '').strip()
if name:
register_template(name, content) Defensive patterns
Strategy: validation
Validate before calling
from llm.prompt.templates import register_template
def safe_register(name: str, template: str) -> None:
if not isinstance(name, str) or not name.strip():
return # skip rather than crash
register_template(name, template) Type guard
def is_valid_template_name(name: object) -> bool:
return isinstance(name, str) and bool(name.strip()) Try / catch
from llm.prompt.templates import register_template
try:
register_template(name, template)
except ValueError:
pass # ignore invalid name Prevention
- Strip and check name before registering; skip registration when falsy.
- Pull template names from a controlled enum or constants module.
- Add unit tests covering '', None, and non-string inputs.
When it happens
Trigger: Calling register_template('', tmpl); register_template(None, tmpl); register_template(123, tmpl); passing a name computed from a missing dict key that defaulted to None.
Common situations: Programmatic template registration from a config where a key was absent; a refactor that introduced an optional name parameter without a default.
Related errors
- Template content must be a non-empty string
- Structured session targets require a non-empty string value
- Pass either config or PromptBuilder keyword options, not bot
- ECC_PROJECT_DIR must be a child path within /workspace.
- Unknown argument: ${arg}
AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13).
Data as JSON: /api/errors/a66e574104c550ff.
Report an issue: GitHub.