Skip to content

fix(line): map LINE msg_type to valid MessageType enum values - #36708

Closed
x1001000 wants to merge 2 commits into
NousResearch:mainfrom
x1001000:fix/line-adapter-messagetype-mapping
Closed

fix(line): map LINE msg_type to valid MessageType enum values#36708
x1001000 wants to merge 2 commits into
NousResearch:mainfrom
x1001000:fix/line-adapter-messagetype-mapping

Conversation

@x1001000

@x1001000 x1001000 commented Jun 1, 2026

Copy link
Copy Markdown

Summary

  • plugins/platforms/line/adapter.py:971 referenced MessageType.IMAGE, which does not exist on gateway.platforms.base.MessageType — every
    non-text inbound LINE message would have raised AttributeError at construction time.
  • Replace the ternary with a line_to_message_type mapping that routes each LINE webhook msg_type to a real enum value: imagePHOTO,
    videoVIDEO, audioVOICE (LINE audio is mic voice notes, so VOICE fires STT + auto-TTS reply per gateway/run.py:8393-8394),
    fileDOCUMENT, stickerSTICKER, locationLOCATION, with TEXT as the default.

Test plan

  • Send a text message via LINE — handled as MessageType.TEXT.
  • Send an image — handled as MessageType.PHOTO.
  • Send a voice note (mic button) — handled as MessageType.VOICE, STT fires.
  • Send a sticker / location — handled with correct enum and no exception.

The previous code referenced MessageType.IMAGE, which doesn't exist on
gateway.platforms.base.MessageType, so any non-text inbound LINE message
would have raised AttributeError. Replace with a proper mapping: LINE's
`audio` (mic voice notes, .m4a) → VOICE so STT and auto-TTS reply fire;
`image` → PHOTO; `file` → DOCUMENT; plus video/sticker/location.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@alt-glitch alt-glitch added type/bug Something isn't working comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have labels Jun 1, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #34233 / #27142 (same root cause: LINE adapter references non-existent MessageType.IMAGE, breaking all non-text inbound messages with AttributeError; same fix mapping msg_type → valid enum values). Consolidating on the earliest canonical fix.

@mxnstrexgl mxnstrexgl left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Automated PR Review

Security Scan

  • ✓ No hardcoded secrets, injection sinks, unsafe deserialization, or dependency red flags found by this automated scan.

Code Quality

  • ✓ No blocking code-quality issues found by this automated scan.
  • ℹ️ No test file changes detected; verify existing coverage exercises this behavior.

Summary

Status: APPROVE — security findings: 0, quality suggestions: 0.

Automated review; raw diff content intentionally omitted.

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Approved

✅ Looks Good

  • Clean refactor: Replaces a binary text/image check with a comprehensive mapping table covering all LINE message types (text, image, video, audio→VOICE, file→DOCUMENT, sticker, location)
  • Correct mapping: LINE audio mics voice notes correctly map to VOICE (enabling STT + auto-TTS), while file for actual audio files maps to DOCUMENT
  • Good documentation: Inline comment explains the audio/file distinction clearly
  • Minimal change: Single function with a well-defined lookup table

Reviewed by Hermes Agent

@x1001000

x1001000 commented Jun 6, 2026

Copy link
Copy Markdown
Author

Closing — the fix already landed on main via an earlier PR. After resolving the conflict by accepting main's version, this PR became a no-op with no net change.

@x1001000 x1001000 closed this Jun 6, 2026
@x1001000
x1001000 deleted the fix/line-adapter-messagetype-mapping branch June 6, 2026 08:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants