Skip to content

fix(db): dedupe lazy-decrypt-view failure logging across sync cycles (#11500) - #11678

Merged
diegosouzapw merged 1 commit into
release/v3.8.51from
fix/11500-decrypt-log-dedup
Aug 26, 2026
Merged

diegosouzapw merged 1 commit into
release/v3.8.51from
fix/11500-decrypt-log-dedup

Conversation

@diegosouzapw

Copy link
Copy Markdown
Collaborator

Refs #11500 (Issue 1 only — the plan-file's Issues 2/3 need a separate scoped design decision and are explicitly out of this PR's scope; Issue 4 was already fixed, no code change needed).

Root cause

The #9927 fix deduped raw [Encryption] Decryption failed... logging only inside decryptConnectionFields(). The lazy-decrypt rollout (createLazyRowProxy/createLazyConnectionView in src/lib/db/providers/lazyConnectionView.ts, used by getProviderConnections() on every CredentialHealth/model-sync cycle) calls decrypt() directly with no {quiet:true} and no dedup tracking — a fresh Proxy wraps a fresh row object every cycle, so the raw failure line re-fires on every single cycle for the same corrupt/stale-key credential.

Fix

New decryptQuiet() wrapper in src/lib/db/encryption.ts shares the existing loggedDecryptFailures Set with decryptConnectionFields(), keyed by (provider, connectionId, field, ciphertext) so a credential already flagged via either path logs at most once. Wired into both createLazyRowProxy and createLazyConnectionView.

Regression test

tests/unit/lazy-connection-view-decrypt-dedupe.test.ts — simulates 3 separate sync cycles over the same corrupt credential via both lazy-decrypt entry points; asserts the raw failure line logs exactly once. Passing 2/2.

Gates run

  • typecheck:core — clean, exit 0
  • eslint --suppressions-location (changed files) — exit 0
  • check-file-size.mjs — OK
  • check-complexity.mjs — OK (2684 vs baseline 2774)
  • check-cognitive-complexity.mjs — OK (1208 vs baseline 1223)
  • check-changelog-integrity.mjs — OK

⚠️ base-red inherited: #11449 — ESLint errors (5), docs-sync migrations count (unrelated to this diff)

@diegosouzapw

Copy link
Copy Markdown
Collaborator Author

Validated in local merge-train (train tip a3a96af7308584900f0fab3ab4afd8499391230a, boarded #11663 #11664 #11665 #11667 #11668 #11669 #11670 #11678 on .113 /srv/omniroute-train) — typecheck:core, file-size, complexity, cognitive-complexity, changelog-integrity all GREEN. npm run test:unit showed 21 failures across 15 test files, none touching this PR's diff; reproduced identically (same test names, same asserts) on origin/release/v3.8.51 alone with zero PRs boarded (targeted re-run, 21/94 fail, same failure set) — confirmed base-red/environment-load drift per merge-gates.md §3, not introduced by any of the 8 boarded PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants