HKUDS/Vibe-Trading · warning · ValueError

Slack target user handle is empty

Error message

Slack target user handle is empty

What it means

User-handle resolution failed because the handle, after normalization (strip, remove leading @, lowercase), is empty.

Source

Thrown at agent/src/channels/slack.py:264

            for channel in response.get("channels", []):
                if self._normalize_target_name(str(channel.get("name") or "")) == normalized:
                    channel_id = str(channel.get("id") or "")
                    if channel_id:
                        self._target_cache[cache_key] = channel_id
                        return channel_id
            cursor = ((response.get("response_metadata") or {}).get("next_cursor") or "").strip()
            if not cursor:
                break

        raise ValueError(
            f"Slack channel '{name}' was not found. Use a joined channel name like "
            f"'#general' or a concrete channel ID."
        )

    async def _resolve_user_handle(self, handle: str) -> str:
        normalized = self._normalize_target_name(handle)
        if not normalized:
            raise ValueError("Slack target user handle is empty")

        cache_key = f"user:{normalized}"
        if cache_key in self._target_cache:
            return self._target_cache[cache_key]

        cursor: str | None = None
        while True:
            response = await self._web_client.users_list(limit=200, cursor=cursor)
            for member in response.get("members", []):
                if self._member_matches_handle(member, normalized):
                    user_id = str(member.get("id") or "")
                    if not user_id:
                        continue
                    dm_id = await self._open_dm_for_user(user_id)
                    self._target_cache[cache_key] = dm_id
                    return dm_id
            cursor = ((response.get("response_metadata") or {}).get("next_cursor") or "").strip()
            if not cursor:

View on GitHub (pinned to 80ffdda44c)

Solutions

  1. Pass a real handle like '@alice' or a user ID (U...)
  2. Validate targets before dispatch
  3. Fix any templating producing empty handles
Defensive patterns

Strategy: validation

Validate before calling

if not handle.strip().lstrip('@'):
    raise ValueError('empty Slack user handle')

Type guard

def is_valid_slack_handle(h: str) -> bool:
    return bool(h and h.strip().lstrip('@'))

Try / catch

except ValueError as e:
    if 'handle is empty' in str(e):
        reject_user_input('invalid user target')

Prevention

When it happens

Trigger: Sending to a target of '@', '', or whitespace interpreted as a user handle.

Common situations: Placeholder target '@username' not filled in, or trailing/odd user input reduced to just '@'.

Related errors


AI-assisted analysis of HKUDS/Vibe-Trading@80ffdda44c (2026-08-28). Data as JSON: /api/errors/24a8458d7cc9300e. Report an issue: GitHub.