Skip to content

fix: stabilize LINE authentication, identity resolution, messaging and tests - #297

Open
meramsey wants to merge 36 commits into
beeper:mainfrom
meramsey:upstream/line-stabilization-20261029
Open

meramsey wants to merge 36 commits into
beeper:mainfrom
meramsey:upstream/line-stabilization-20261029

Conversation

@meramsey

Copy link
Copy Markdown

Summary

  • Restore friendly login, login help, login qr, and login email dispatch while preserving mautrix-go flow IDs and permission checks.
  • Harden QR/email authentication with serialized account operations, structured/redacted provider errors, Retry-After and per-account cooldown handling, and safe reconnect behavior.
  • Validate public LINE IDs and MID results before portal creation, preserve opaque case-sensitive gateway IDs, and reuse/reopen canonical DM portals.
  • Preserve outbound cancellation/error acknowledgements and inbound media authentication/metadata behavior.
  • Keep the current upstream contact-search result cap, cancellation checks, and context-aware avatar requests from connector: keep contact search bounded and stop it when the request is canceled #296.
  • Include targeted regression tests, coverage gates, optimized test modes/caches, and reproducible Linux release tooling.

Root causes

  • The upstream-first rebuild omitted the LINE-specific login command registration from LineConnector.Init, leaving only mautrix-go's fully qualified flow-ID parser; login qr was therefore rejected even though QR authentication remained enabled.
  • Earlier lookup and media paths accepted insufficiently validated provider identities/results or lost useful cancellation/error classification. The follow-up changes validate data before persisting portals and keep sensitive provider data out of surfaced diagnostics.

Relationship to existing PRs

Validation

  • Targeted login, public-ID/MID/opaque identity, start-chat/portal reuse, QR lifecycle, provider errors, and cooldown tests passed.
  • normal: 512 pass events, 1 skip, 0 failures.
  • race: 512 pass events, 1 skip, 0 failures.
  • coverage: 512 pass events, 1 skip, 0 failures; package coverage gates passed.
  • release: all above checks, gofmt, go vet, staticcheck, go mod verify, coverage-checker tests, and build passed.
  • Release source is checkpoint f36c646b468719877c9fb4329f2cab18b652fbca; reproducible Linux amd64 builds with Go 1.26.10 and libolm 3.2.16 were byte-identical.

Compatibility and limitations

  • Existing fully qualified login flow IDs and network.qr_login configuration remain supported.
  • Optional historical lookup-shape diagnostics are intentionally deferred pending current-schema/privacy review; safe lookup validation remains.
  • Live QR/provider behavior and the known Matrix E2EE puppet sender/device warning require operator verification. No live account actions or encryption changes were performed.
  • No production deployment was performed as part of this integration task.

meramsey and others added 30 commits October 28, 2026 05:32
Adapt beeper#196 (a6d06b0) to the shared media decryptor, covering both uploads and direct media. Preserve upstream fail-closed key fallback and route video to chunk-hash HMAC verification. Add valid, tampered and wrong-mode coverage for all media kinds.

Co-authored-by: Adrien Vermersch <adrien.vermersch@devolab.net>
Select the image metadata changes from beeper#189 at a4d8c11, retaining current download, size-limit and authentication handling. Keep the separate 60-retry OBS policy out of this scoped fix. Includes bounded ISO-BMFF brand detection and regression tests.

Co-authored-by: Adrien Vermersch <adrien.vermersch@devolab.net>
Replace 6000 expensive eviction cache misses with three complete cache rotations, per-call victim and LRU assertions, and explicit refresh-boundary coverage. Preserve the separate 6000-call reuse and real heap-exhaustion tests. Give cold signing a separate setup budget while retaining the one-second cancellation bound; cancel and join the request worker on every exit path.
Share exact identifier lookup with search, validate canonical user MIDs and reuse returned contact data. Delay portal persistence until remote resolution succeeds, honor lookup-only requests, and pass complete DM information to bridgev2. Add cancellable lookup RPCs and isolated database regressions for identity consistency, errors, cancellation, concurrent portal reuse and Matrix creation retries.
Reject overlapping Start/Wait calls before they consume polling stages or mutate authentication state. Preserve caller and attempt expiry instead of reporting every canceled start as context.Canceled. Reproduce both defects and cover mocked QR presentation, scan/PIN approval, token verification, missing-keychain persistence rejection, expiry and cancellation.
Add a typed AuthError model in pkg/line that normalizes LINE provider
exceptions into stable categories. QR RPC errors now carry a structured
AuthError; the connector uses it to choose user-facing messages, apply
per-account cooldowns, and emit sanitized log fields.

- Introduce AuthErrorCategory/AuthErrorStage enums and AuthError struct.
- Build AuthError from qrRPCError with safe provider-reason/alert handling.
- Export QRRPCError alias so callers can access AuthError().
- Map SecondaryQrCodeException codes and TalkException codes to categories.
- Classify email login errors into the same categories.
- Add 10-minute cooldown for verification-temporarily-unavailable errors.
- Log structured auth_error_* fields for QR failures.
- Prevent raw provider reason strings from leaking into user-facing email
  login messages.
- Add regression tests for classification, cooldowns, and provider-text
  redaction.
- Make build.sh honor SOURCE_DATE_EPOCH for reproducible builds.
- Update QR_REGRESSION_AUDIT.md with structured-error and cooldown docs.
Allow build.sh to be used with -o and other go build flags that must
appear before the package argument.
Expose the existing native malloc/free alongside ModuleMem for bounded resource fixtures. Prefill the real signing heap, then retain the original real key-allocation abort, recovery, signature and E2EE-isolation assertions. Keep the 6000-signature and 1800-decryption stress loops unchanged. Add allocation isolation, exhaustion and coalescing/reuse tests; generated crypto and default runtime behavior are unchanged.
Use synctest quiescence to check the album-preview worker limit without scheduler-dependent sleeping. Keep ordering and concurrency assertions and bounded failure guards. Write crypto vectors to t.TempDir with mandatory write checks and test-scoped logging, enabling safe parallel execution of the two independent vector tests.
Pass the Matrix request context to sendMessage, preserve structured TalkException details for existing recovery logic, and reject missing acknowledgements instead of returning success or dereferencing nil. Add correlated send-stage logs without message bodies and regressions for ownership, canonical recipients, API failures and cancellation. These defects are reproduced locally; the reported live Element delivery failure still needs event-level evidence.
Verify public-ID reopening after leaving a Matrix room, rejection of mismatched MIDs and expired lookup requests, and mandatory fresh approval for passwordless QR sessions after token recovery is unavailable.
Label existing connect, LINE fullSync and post-backfill synchronization triggers without changing policy. Document canonical DM resolution, retained retryable portal rows, outbound stage/account diagnostics, independent QR lifecycle findings and live-verification boundaries.
Label connection, LINE fullSync and historical-state reconciliation without changing sync behavior. Document canonical identity resolution, portal retry/reopening, outbound correlation and ownership checks, QR lifecycle fixes, mocked coverage and remaining live-verification requirements.
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.

2 participants