Skip to content

Fix @ai answers failing with "name 'chan_name' is not defined" - #11

Merged
raf-li merged 1 commit into
mainfrom
fix/ai-chat-chan-name
Oct 5, 2026
Merged

raf-li merged 1 commit into
mainfrom
fix/ai-chat-chan-name

Conversation

@raf-li

@raf-li raf-li commented Oct 5, 2026

Copy link
Copy Markdown
Member

Problem

Since bb518fc ("support @ai via PM") every @ai question fails; the server log shows:

ai_chat: AI chat failed: name 'chan_name' is not defined

When the asker line in AIChat.answer() was split into a PM and a channel variant, the line that sets chan_name was removed, but both variants still use it.

Fix

Restore chan_name = context.get("channel_name") or f"channel {context.get('channel')}".

Testing

  • pyflakes ai_chat.py: no undefined names left.
  • answer() with a stubbed Workers AI call: channel question, PM question and a context without channel_name all return the answer with the right "Penanya: ..." line.

🤖 Generated with Claude Code

Splitting the asker line into PM and channel variants dropped the line
that sets chan_name, so every @ai question (channel and PM) failed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@raf-li
raf-li merged commit ab33feb into main Oct 5, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant