{"record":{"id":"b6574a36a6a76d18","repo":"chenhg5/cc-connect","slug":"matrix-init-verification-w","errorCode":null,"errorMessage":"matrix: init verification: %w","messagePattern":"matrix: init verification: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/matrix/verification.go","lineNumber":222,"sourceCode":"\n\t// Wrap the client's actual HTTP transport. We must use client.Client directly\n\t// (not p.httpClient) because cryptohelper.Init() may have replaced client.Client\n\t// with a new http.Client instance.\n\tif client.Client == nil {\n\t\treturn fmt.Errorf(\"matrix: client http.Client is nil\")\n\t}\n\tbase := client.Client.Transport\n\tif base == nil {\n\t\tbase = http.DefaultTransport\n\t}\n\tclient.Client.Transport = &encryptingTransport{base: base, p: p}\n\tslog.Info(\"matrix: transport wrapped for verification encryption\")\n\n\tcallbacks := &verificationCallbacks{platform: p}\n\thelper := verificationhelper.NewVerificationHelper(client, ch.Machine(), nil, callbacks, false, false, true)\n\n\tif err := helper.Init(ctx); err != nil {\n\t\treturn fmt.Errorf(\"matrix: init verification: %w\", err)\n\t}\n\n\tp.setVerificationHelper(helper)\n\tslog.Info(\"matrix: verification helper initialized and event handlers registered\")\n\treturn nil\n}\n\n// handleVerificationMAC works around a mautrix library bug where\n// onVerificationMAC uses GetOwnCrossSigningPublicKeys() instead of the other\n// user's cross-signing keys for cross-user verification. This causes \"unknown\n// key ID\" errors when verifying devices belonging to a different user.\n//\n// Instead of dispatching the MAC event to the buggy handler, we trust the\n// device directly and send a verification done event. The SAS emoji comparison\n// already proved both sides share the same secret, so this is safe for\n// auto-verify bots.\nfunc (p *Platform) handleVerificationMAC(ctx context.Context, client *mautrix.Client, ch *cryptohelper.CryptoHelper, evt *event.Event) {\n\t// Extract transaction ID (already fixed by CustomPostDecrypt to be the request event ID)","sourceCodeStart":204,"sourceCodeEnd":240,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/matrix/verification.go#L204-L240","documentation":"initVerification wraps a failure from VerificationHelper.Init(ctx) with \"matrix: init verification: %w\". The helper initializes olm/megolm session handling and registers event handlers for interactive device verification; a failure here means the crypto machine or its state store rejected initialization. The original error is preserved in the wrap.","triggerScenarios":"helper.Init(ctx) returns an error — typically because the OlmMachine's crypto store is inaccessible/corrupt, keys cannot be loaded, or the client is not properly synced — inside initVerification.","commonSituations":"SQLite/sql crypto store file locked by another cc-connect instance; corrupted crypto store after an unclean shutdown; mismatched store schema after a library upgrade; account keys not found because the store directory was moved or deleted.","solutions":["Read the wrapped cause (%w) in logs to identify the underlying failure","Verify the crypto store path is writable and not locked by another process","If the store is corrupt, back it up and remove it so keys are re-created (devices will need re-verification)","After a library upgrade, check for store schema migration notes; downgrade or migrate the store accordingly"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// check store accessibility before init\nif f, err := os.OpenFile(storePath, os.O_RDWR, 0o600); err != nil {\n    // crypto store not usable\n} else { f.Close() }","typeGuard":null,"tryCatchPattern":"if err := helper.Init(ctx); err != nil {\n    slog.Error(\"matrix: verification helper init failed\", \"cause\", errors.Unwrap(err))\n    return fmt.Errorf(\"matrix: init verification: %w\", err)\n}","preventionTips":["Ensure only one cc-connect instance uses a given crypto store","Back up the crypto store before upgrades","Read the wrapped cause to distinguish store-lock vs schema issues"],"tags":["matrix","e2ee","verification","crypto-store"],"backgroundTag":"module-init-failed","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}