Skip to content

fix: refresh auth issue#202

Merged
highesttt merged 2 commits into
mainfrom
highest/plat-37762
Jul 1, 2026
Merged

fix: refresh auth issue#202
highesttt merged 2 commits into
mainfrom
highest/plat-37762

Conversation

@highesttt

Copy link
Copy Markdown
Collaborator

No description provided.

@linear-code

linear-code Bot commented Jul 1, 2026

Copy link
Copy Markdown

PLAT-37762

@indent-zero

indent-zero Bot commented Jul 1, 2026

Copy link
Copy Markdown
Contributor
PR Summary

Replaces the previous behavior of embedding [Unable to decrypt message. Open an issue on GitHub.] directly in a Matrix text event when LINE E2EE decryption fails. decryptMessageBody now clears bodyText before attempting decryption, treats an inbound message whose text already equals the historical placeholder as still-needing-decryption, and returns a decryptionFailed bool. convertLineMessage uses that signal to emit a Matrix MsgNotice with body [Unable to decrypt LINE message.] for text messages, giving users a clearer marker without the misleading "Open an issue" phrasing.

  • Added lineDecryptFallbackText and lineDecryptFailureNoticeText constants plus isLineDecryptFallbackText helper in pkg/connector/handle_message.go.
  • Reworked decryptMessageBody to reset bodyText to "" before decryption and to return a decryptionFailed bool that flips to false only on successful decrypt (1:1 or group, on either the first attempt or the retry).
  • convertLineMessage now takes decryptionFailed and emits a MsgNotice (preserving reply relations) when it's set and the message is text-only; wired through both the live path (queueIncomingMessage) and the backfill path (sync.go: FetchMessages).
  • Added pkg/connector/handle_message_test.go with four unit tests covering the pre-decrypt reset, the historical-placeholder guard, the "no chunks" pass-through, and the notice emission for decryption failures.

Issues

All clear! No issues remaining. 🎉

3 issues already resolved
  • The isLineDecryptFallbackText guard only fires against a state that LINE never produces: msg.Text comes straight from the LINE API and has no knowledge of the bridge's Go constant, and this PR removes the only code path that ever wrote the placeholder back. In practice the disjunct is reachable only if a real user literally types the placeholder string in an E2EE chat. (fixed by commit 4985641)
  • The new tests never exercise the decrypt-failure path: all three construct &LineClient{} with E2EE == nil, so the entire if lc.E2EE != nil block is skipped and the tests only re-assert the pre-decrypt reset of bodyText. The invariant this PR actually changes ("decrypt fails → bodyText stays empty instead of placeholder") is not guarded. (fixed by commit 4985641)
  • Undecryptable text messages are now silently dropped: with bodyText staying "" on decrypt failure, convertLineMessage hits the strings.TrimSpace(unwrappedText) == "" branch and returns (nil, nil), so no Matrix event is emitted and the user has no in-room signal that a message failed to decrypt. (fixed by commit 4985641)

CI Checks

Waiting for CI checks...

@coderabbitai

coderabbitai Bot commented Jul 1, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7e613fa9-2dd9-444c-962a-88a2a41d7940

📥 Commits

Reviewing files that changed from the base of the PR and between bbb1a5d and 4985641.

📒 Files selected for processing (3)
  • pkg/connector/handle_message.go
  • pkg/connector/handle_message_test.go
  • pkg/connector/sync.go
📜 Recent review details
⏰ Context from checks skipped due to timeout. (4)
  • GitHub Check: Lint with 1.25
  • GitHub Check: build-docker
  • GitHub Check: build-docker
  • GitHub Check: Lint with 1.25
🧰 Additional context used
📓 Path-based instructions (2)
**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

**/*.go: Use go fmt for code formatting across all Go files
Use goimports with -local "github.com/highesttt/matrix-line-messenger" flag to group project-local imports correctly
Use zerolog for logging throughout the codebase
Do not use Msgf in logging; use Msg with structured fields instead
Use Stringer interface where applicable in Go code

Files:

  • pkg/connector/sync.go
  • pkg/connector/handle_message_test.go
  • pkg/connector/handle_message.go
**/!(ltsm)/**/*.go

📄 CodeRabbit inference engine (AGENTS.md)

**/!(ltsm)/**/*.go: Run staticcheck on all Go files excluding pkg/ltsm package (transpiled WASM code)
Run go vet on all Go files excluding pkg/ltsm package (transpiled WASM code)

Files:

  • pkg/connector/sync.go
  • pkg/connector/handle_message_test.go
  • pkg/connector/handle_message.go
🔇 Additional comments (5)
pkg/connector/handle_message_test.go (3)

11-33: Duplicate: decrypt failure tests still bypass the E2EE failure paths.

These tests instantiate &LineClient{} with E2EE == nil, so they don’t exercise the “E2EE present, decrypt/retry failed” invariant already flagged in the previous review.


35-72: LGTM!


47-48: 🎯 Functional Correctness

No issue: t.Context() is supported by the declared Go 1.25 toolchain and CI pin.

pkg/connector/handle_message.go (1)

26-30: LGTM!

Also applies to: 129-146, 213-321, 323-346

pkg/connector/sync.go (1)

339-340: LGTM!


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of messages that can’t be decrypted, so they now surface as a clear notice instead of appearing empty or misleading.
    • Preserved existing text behavior when decryption isn’t involved, avoiding unintended changes for normal messages.
    • Applied the same decryption-failure handling consistently during message backfill and live message processing.
  • Tests
    • Added coverage for decryption failure detection and the new notice-based message conversion behavior.

Walkthrough

This PR adds decryption-failure detection to decryptMessageBody, which now returns a third decryptionFailed boolean. convertLineMessage uses this to render a Matrix notice instead of fallback text when decryption fails on text messages. Call sites in queueIncomingMessage and FetchMessages are updated, with new tests added.

Changes

Decrypt failure detection and notice conversion

Layer / File(s) Summary
Decrypt failure detection
pkg/connector/handle_message.go
Adds fallback-marker and notice-text constants; decryptMessageBody now returns a decryptionFailed flag, true when text is empty or matches the historical fallback marker, false on successful group or 1-1 decryption.
Notice conversion and call-site wiring
pkg/connector/handle_message.go, pkg/connector/sync.go
convertLineMessage accepts decryptionFailed and returns a Matrix notice with the new notice text when decryption failed on blank text messages; queueIncomingMessage and FetchMessages capture and pass the flag through.
Tests for decrypt failure and notice behavior
pkg/connector/handle_message_test.go
New tests validate decryptMessageBody's failure flag across unavailable decryption, fallback-marker text, and no-chunk scenarios, and confirm convertLineMessage returns a notice with the distinct failure text.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant queueIncomingMessage
  participant FetchMessages
  participant decryptMessageBody
  participant convertLineMessage
  queueIncomingMessage->>decryptMessageBody: decrypt(msg)
  decryptMessageBody-->>queueIncomingMessage: bodyText, unwrappedText, decryptionFailed
  queueIncomingMessage->>convertLineMessage: convert(..., decryptionFailed)
  convertLineMessage-->>queueIncomingMessage: notice or converted message
  FetchMessages->>decryptMessageBody: decrypt(msg)
  decryptMessageBody-->>FetchMessages: bodyText, unwrappedText, decryptionFailed
  FetchMessages->>convertLineMessage: convert(..., decryptionFailed)
  convertLineMessage-->>FetchMessages: notice or converted message
Loading
🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title mentions an auth refresh issue, but the changes actually add LINE message decryption-failure handling and notice conversion. Retitle it to reflect the real change, such as "Handle LINE message decryption failures with notice messages".
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ❓ Inconclusive No pull request description was provided, so there isn't enough text to assess whether it matches the changeset. Add a brief description summarizing the decryption-failure handling and notice-message changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch highest/plat-37762

Comment @coderabbitai help to get the list of available commands.

Comment thread pkg/connector/handle_message.go
Comment thread pkg/connector/handle_message_test.go Outdated
Comment thread pkg/connector/handle_message.go
@highesttt highesttt merged commit ae8aae0 into main Jul 1, 2026
9 of 10 checks passed
@highesttt highesttt deleted the highest/plat-37762 branch July 1, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant