musiclink/docs/reviews/message-handling.md

1 KiB

Code Review: Message Handling & Link Logic

Scope

  • internal/handler/
  • internal/detector/
  • internal/resolver/
  • internal/services/

Findings

Strengths

  • Clear separation between detection, resolution, and formatting.
  • Resolver wraps API errors with context; bounded error body capture improves diagnostics.
  • Service ordering is explicit and consistent in formatting output.

⚠️ Issues / Opportunities

  1. Detector regex is brittle

    • Centralized regex is dense and risks missing edge cases; updates require careful regex edits.
    • Consider migrating to per-service patterns or table-driven detection.
  2. Plain-text only parsing

    • HandleText only uses raw body; formatted/HTML links are ignored.
    • Decision made to keep plaintext-only; document this limitation.
  3. Single-link handling

    • Handler uses links[0] only; multiple links ignored (by design).
    • Explicitly document or consider multi-link responses in future.

Notes

  • Qobuz now supported end-to-end (detector + mapping + formatter).