HKUDS/nanobot · error · ValueError

Slack DM target for user '{user_id}' could not be opened.

Error message

Slack DM target for user '{user_id}' could not be opened.

What it means

Error "Slack DM target for user '{user_id}' could not be opened." thrown in HKUDS/nanobot.

Source

Thrown at nanobot/channels/slack/runtime.py:386

            )
            cursor = str(response_metadata.get("next_cursor") or "").strip()
            if not cursor:
                break

        raise ValueError(
            f"Slack user '{handle}' was not found. Use '@name' or a concrete DM/channel ID."
        )

    async def _open_dm_for_user(self, user_id: str) -> str:
        web_api = self._require_web_api()
        response = cast(
            dict[str, Any],
            await web_api.conversations_open(users=user_id),
        )
        channel = cast(dict[str, Any], response.get("channel") or {})
        channel_id = str(channel.get("id") or "")
        if not channel_id:
            raise ValueError(f"Slack DM target for user '{user_id}' could not be opened.")
        return channel_id

    @staticmethod
    def _normalize_target_name(value: str) -> str:
        return value.strip().lstrip("#@").lower()

    @classmethod
    def _member_matches_handle(cls, member: dict[str, Any], normalized: str) -> bool:
        profile = cast(dict[str, Any], member.get("profile") or {})
        candidates = {
            str(member.get("name") or ""),
            str(profile.get("display_name") or ""),
            str(profile.get("display_name_normalized") or ""),
            str(profile.get("real_name") or ""),
            str(profile.get("real_name_normalized") or ""),
        }
        return normalized in {cls._normalize_target_name(candidate) for candidate in candidates if candidate}

View on GitHub (pinned to 42f37dc4c0)

When it happens

Trigger: Thrown at nanobot/channels/slack/runtime.py:386 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/d1fb271781a0eb46. Report an issue: GitHub.