HKUDS/nanobot · error · TypeError

ChannelPlugin.management.instance_specs for

Error message

ChannelPlugin.management.instance_specs for '{plugin.name}' returned an invalid item

What it means

Raised by channel_instance_specs when the plugin's instance_specs result contains items that are not valid ChannelInstanceSpec objects (wrong type returned from user plugin code). The adapter contract is violated.

Solutions

  1. Return only ChannelInstanceSpec instances from instance_specs
  2. Check that the factory does not yield raw dicts or tuples
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at nanobot/channels/contracts.py:347 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/0981dc526ad68456. Report an issue: GitHub.

Appendix: source

Thrown at nanobot/channels/contracts.py:347

) -> list[ChannelInstanceSpec]:
    """Expand persisted config through the dependency-free management adapter."""
    factory = plugin.management.instance_specs
    if factory is None:
        activation = ChannelActivation.from_config(section)
        raw_specs: object = (
            []
            if enabled_only and not activation.resolve(default=plugin.default_enabled)
            else [ChannelInstanceSpec(instance_id="default", config=section)]
        )
    else:
        raw_specs = cast(object, factory(section, enabled_only=enabled_only))
    if not isinstance(raw_specs, Iterable):
        raise TypeError(
            f"ChannelPlugin.management.instance_specs for '{plugin.name}' must return an iterable"
        )
    specs = list(cast(Iterable[object], raw_specs))
    if not _all_channel_instance_specs(specs):
        raise TypeError(
            f"ChannelPlugin.management.instance_specs for '{plugin.name}' returned an invalid item"
        )

    instance_ids: set[str] = set()
    runtime_names: set[str] = set()
    for spec in specs:
        instance_id = cast(object, spec.instance_id)
        if not isinstance(instance_id, str) or not instance_id.strip():
            raise ValueError(
                f"ChannelPlugin.management.instance_specs for '{plugin.name}' returned an empty instance id"
            )
        if spec.instance_id in instance_ids:
            raise ValueError(
                f"ChannelPlugin.management.instance_specs for '{plugin.name}' returned duplicate instance id "
                f"'{spec.instance_id}'"
            )
        runtime_name = channel_runtime_name(plugin, spec.instance_id)
        if runtime_name in runtime_names:

View on GitHub (pinned to 42f37dc4c0)