HKUDS/nanobot · error · ValueError
instance id must match [A-Za-z0-9_-]+
Error message
instance id must match [A-Za-z0-9_-]+
What it means
Raised by validate_instance_id when the Feishu instance id is empty after stripping or fails the ^[A-Za-z0-9_-]+$ fullmatch. Instance ids become config keys and runtime names, so character hygiene is enforced.
Solutions
- Use ids like 'default' or 'assistant-2' with only [A-Za-z0-9_-] characters
- Remove spaces, dots, and unicode characters from the instance id
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at nanobot/channels/feishu/instances.py:22 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of HKUDS/nanobot@42f37dc4c0 (2026-08-26).
Data as JSON: /api/errors/08ced7403a607983.
Report an issue: GitHub.
Appendix: source
Thrown at nanobot/channels/feishu/instances.py:22
import re
from typing import Any, cast
from loguru import logger
from nanobot.channels.contracts import ChannelInstanceSpec, ChannelManagementSpec
from nanobot.channels.feishu.config import feishu_default_config
from nanobot.config.loader import merge_missing_defaults
DEFAULT_INSTANCE_ID = "default"
_INSTANCE_ID_RE = re.compile(r"^[A-Za-z0-9_-]+$")
def validate_instance_id(value: str) -> str:
"""Return a normalized instance id or raise ValueError."""
instance_id = value.strip()
if not instance_id or not _INSTANCE_ID_RE.fullmatch(instance_id):
raise ValueError("instance id must match [A-Za-z0-9_-]+")
return instance_id
def runtime_channel_name(base_name: str, instance_id: str) -> str:
"""Return the channel key used for routing messages at runtime."""
return base_name if instance_id == DEFAULT_INSTANCE_ID else f"{base_name}.{instance_id}"
def managed_feishu_instance_specs(
section: Any,
*,
enabled_only: bool = True,
) -> list[ChannelInstanceSpec]:
return feishu_instance_specs(
section,
feishu_default_config(),
enabled_only=enabled_only,
)View on GitHub (pinned to 42f37dc4c0)