fix: missing encryption fallback for certain groups#201
Conversation
|
📝 WalkthroughSummary by CodeRabbit
WalkthroughE2EE public-key negotiation and fetch paths now go through callLineResult wrappers, with token recovery routed through a helper closure. ensurePeerKey and ensurePeerKeyByID use their context parameters, and new tests cover auth recovery retries and negative caching. ChangesE2EE key retrieval refactor
Estimated code review effort: 2 (Simple) | ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pkg/connector/e2ee_keys_test.go`:
- Around line 17-25: The test helper newPeerKeyTestClient currently seeds
recoverTime with time.Now(), which causes recoverToken() to stay inside
recentTokenRecoveryWindow and skip the retry path. Update LineClient
construction in newPeerKeyTestClient so recoverTime is left unset or initialized
outside the cooldown window, allowing the auth-error retry tests to exercise
refresh/re-login behavior through recoverToken().
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f1f60cb0-7cd5-499a-9185-59104b56731d
📒 Files selected for processing (2)
pkg/connector/e2ee_keys.gopkg/connector/e2ee_keys_test.go
📜 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: Usego fmtfor code formatting across all Go files
Usegoimportswith-local "github.com/highesttt/matrix-line-messenger"flag to group project-local imports correctly
Usezerologfor logging throughout the codebase
Do not useMsgfin logging; useMsgwith structured fields instead
UseStringerinterface where applicable in Go code
Files:
pkg/connector/e2ee_keys_test.gopkg/connector/e2ee_keys.go
**/!(ltsm)/**/*.go
📄 CodeRabbit inference engine (AGENTS.md)
**/!(ltsm)/**/*.go: Runstaticcheckon all Go files excludingpkg/ltsmpackage (transpiled WASM code)
Rungo veton all Go files excludingpkg/ltsmpackage (transpiled WASM code)
Files:
pkg/connector/e2ee_keys_test.gopkg/connector/e2ee_keys.go
🔇 Additional comments (2)
pkg/connector/e2ee_keys.go (1)
16-24: LGTM!Also applies to: 98-98, 119-121, 318-318, 332-335
pkg/connector/e2ee_keys_test.go (1)
1-16: LGTM!Also applies to: 27-136
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pkg/connector/auth_recovery.go (1)
17-20: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueGlobal mutable var used as a test seam is race-prone.
recoverLineTokenis a package-levelvarfunction used purely to allow overriding recovery behavior (likely for tests in the upcominge2ee_keys_test.golayer). Reassigning a shared package-level var across tests is unsynchronized global mutable state — if tests run witht.Parallel(), or overrides aren't restored viat.Cleanup, this risks data races and test pollution. Also, by Go conventioncontext.Contextshould be the first parameter.Consider injecting the recovery function via a struct field on
LineClient(or vialineCallDeps.recoverdirectly, already present) instead of a global var, so each test/call site can supply its own recovery function without touching shared state.♻️ Suggested refactor
-var recoverLineToken = func(lc *LineClient, ctx context.Context) error { - return lc.recoverToken(ctx) -} +func recoverLineToken(ctx context.Context, lc *LineClient) error { + return lc.recoverToken(ctx) +}And for tests, prefer injecting a stub directly into
lineCallDeps.recover(already a func field) rather than swapping the package-level var.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pkg/connector/auth_recovery.go` around lines 17 - 20, The package-level recoverLineToken var is shared mutable state and should not be used as a test seam. Move token recovery injection onto LineClient or use the existing lineCallDeps.recover func field so each instance/call can supply its own implementation, and update the recovery helper signature to follow Go convention with context.Context first. Adjust any callers in LineClient/recovery flow to use the injected dependency instead of reassigning the global var.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@pkg/connector/auth_recovery.go`:
- Around line 17-20: The package-level recoverLineToken var is shared mutable
state and should not be used as a test seam. Move token recovery injection onto
LineClient or use the existing lineCallDeps.recover func field so each
instance/call can supply its own implementation, and update the recovery helper
signature to follow Go convention with context.Context first. Adjust any callers
in LineClient/recovery flow to use the injected dependency instead of
reassigning the global var.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: aede692c-c586-40e1-8069-7214edb6f649
📒 Files selected for processing (2)
pkg/connector/auth_recovery.gopkg/connector/e2ee_keys_test.go
🚧 Files skipped from review as they are similar to previous changes (1)
- pkg/connector/e2ee_keys_test.go
📜 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: Usego fmtfor code formatting across all Go files
Usegoimportswith-local "github.com/highesttt/matrix-line-messenger"flag to group project-local imports correctly
Usezerologfor logging throughout the codebase
Do not useMsgfin logging; useMsgwith structured fields instead
UseStringerinterface where applicable in Go code
Files:
pkg/connector/auth_recovery.go
**/!(ltsm)/**/*.go
📄 CodeRabbit inference engine (AGENTS.md)
**/!(ltsm)/**/*.go: Runstaticcheckon all Go files excludingpkg/ltsmpackage (transpiled WASM code)
Rungo veton all Go files excludingpkg/ltsmpackage (transpiled WASM code)
Files:
pkg/connector/auth_recovery.go
🔇 Additional comments (1)
pkg/connector/auth_recovery.go (1)
60-60: LGTM! Passthrough wiring preserves existing recovery semantics (runTokenRecoverylocking/negative-window behavior unchanged perclient.go).Also applies to: 79-79
No description provided.