Skip to content

fix(vikingbot):修复bot定时任务发送飞书消息reply_to为none时报错#2524

Open
tewbie wants to merge 1 commit into
volcengine:mainfrom
tewbie:main
Open

fix(vikingbot):修复bot定时任务发送飞书消息reply_to为none时报错#2524
tewbie wants to merge 1 commit into
volcengine:mainfrom
tewbie:main

Conversation

@tewbie

@tewbie tewbie commented Jun 9, 2026

Copy link
Copy Markdown

Description

修复定时任务发送飞书消息提示的错误
vikingbot.channels.feishu:send:671 - Error sending Feishu message: 'NoneType' object has no attribute 'startswith'

Related Issue

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • Test update

Changes Made

Testing

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have tested this on the following platforms:
    • Linux
    • macOS
    • Windows

Checklist

  • My code follows the project's coding style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

Screenshots (if applicable)

img_v3_0212f_66faa411-c9e5-48aa-90d9-b0b94b7cb6bg

Additional Notes

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
🏅 Score: 75
🧪 No relevant tests
🔒 No security concerns identified
✅ No TODO sections
🔀 No multiple PR themes
⚡ Recommended focus areas for review

Possible Regression

After attempting to retrieve reply_to from session_key, reply_to could still be None, leading to the same AttributeError when calling startswith("oc_"). Need to handle None case explicitly.

reply_to = msg.metadata.get("reply_to")
if reply_to is None and hasattr(msg, "session_key"):
    reply_to = getattr(msg.session_key, "chat_id", None)
if reply_to.startswith("oc_"):
    receive_id_type = "chat_id"
else:
    receive_id_type = "open_id"

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
Possible issue
Prevent AttributeError from None reply_to

Add a check to ensure reply_to is not None before calling startswith() to avoid
AttributeError. If reply_to remains None after both attempts, return early as we
can't determine the recipient.

bot/vikingbot/channels/feishu.py [557-560]

 reply_to = msg.metadata.get("reply_to")
 if reply_to is None and hasattr(msg, "session_key"):
     reply_to = getattr(msg.session_key, "chat_id", None)
+if reply_to is None:
+    return
 if reply_to.startswith("oc_"):
Suggestion importance[1-10]: 8

__

Why: The suggestion prevents an AttributeError by checking if reply_to is None before calling startswith(), and returns early if no recipient can be determined, addressing a potential crash bug in the message sending logic.

Medium

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

1 participant