Skip to content

fix(line): use stable source id for session identity - #2398

Open
leonoxo wants to merge 1 commit into
langbot-app:masterfrom
leonoxo:fix/line-session-identity
Open

fix(line): use stable source id for session identity#2398
leonoxo wants to merge 1 commit into
langbot-app:masterfrom
leonoxo:fix/line-session-identity

Conversation

@leonoxo

@leonoxo leonoxo commented Aug 4, 2026

Copy link
Copy Markdown

Summary

  • LINEEventConverter.target2yiri() built Friend.id/Group.id (and the GroupMember sender id) from event.message.id, which is unique per message — every incoming message therefore mapped to a different session key, so LINE users and groups lost conversation context on every single turn.
  • Switched to event.source.user_id/.group_id/.room_id, the stable identifiers LINE actually provides for this purpose, matching the pattern already used by other adapters (e.g. telegram.py uses event.effective_chat.id).
  • Falls back to the group/room id when user_id is absent, per LINE's documented behavior ("Only included in message events. Only users of LINE for iOS and LINE for Android are included in userId") for some group/room members.

Test plan

  • Added tests/unit_tests/platform/test_line_session_identity.py covering: stable sender id across multiple messages from the same user, stable group id across multiple messages, and room-type fallback when user_id is missing.
  • uv run pytest tests/unit_tests/platform/test_line_session_identity.py tests/unit_tests/platform/test_line_limits.py -q — 6 passed
  • uv run ruff check / ruff format --check on changed files

LINEEventConverter.target2yiri() built Friend.id/Group.id from
event.message.id, which is unique per message. Every incoming message
therefore mapped to a new session key, so LINE users and groups lost
conversation context on every turn.

Use event.source.user_id/group_id/room_id instead, matching the stable
identifiers other adapters (e.g. Telegram) use for session identity.
Falls back to the group/room id when user_id is absent, per LINE's
documented behavior for some group/room members.
@dosubot dosubot Bot added size:S This PR changes 10-29 lines, ignoring generated files. eh: Improve enhance: 现有功能的改进 / improve current features m: Platform 机器人管理相关 / Bots management m: Session 会话和消息模块 / Sessions management labels Aug 4, 2026
@github-actions

github-actions Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

All contributors have signed the CLA. ✅ 所有贡献者均已签署 CLA。
Posted by the CLA Assistant Lite bot.

@leonoxo

leonoxo commented Aug 4, 2026

Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@RockChinQ

Copy link
Copy Markdown
Member

Hi @leonoxo , would you provide some screenshots to prove the changes work?

@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

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

Labels

eh: Improve enhance: 现有功能的改进 / improve current features m: Platform 机器人管理相关 / Bots management m: Session 会话和消息模块 / Sessions management size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants