1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-25 05:23:13 +03:00

Improve decryption failure logging (#2453)

* Improve typing

* Log the actual errors to include call stacks
This commit is contained in:
Michael Telatynski
2022-06-13 13:26:01 +01:00
committed by GitHub
parent aaf508e309
commit 4897bccdc9
5 changed files with 14 additions and 13 deletions

View File

@@ -92,7 +92,7 @@ export interface InboundGroupSessionData {
sharedHistory?: boolean;
}
interface IDecryptedGroupMessage {
export interface IDecryptedGroupMessage {
result: string;
keysClaimed: Record<string, string>;
senderKey: string;
@@ -100,6 +100,11 @@ interface IDecryptedGroupMessage {
untrusted: boolean;
}
export interface IInboundSession {
payload: string;
session_id: string;
}
export interface IExportedDevice {
pickleKey: string;
pickledAccount: string;
@@ -620,7 +625,7 @@ export class OlmDevice {
theirDeviceIdentityKey: string,
messageType: number,
ciphertext: string,
): Promise<{ payload: string, session_id: string }> { // eslint-disable-line camelcase
): Promise<IInboundSession> {
if (messageType !== 0) {
throw new Error("Need messageType == 0 to create inbound session");
}

View File

@@ -30,7 +30,7 @@ import {
registerAlgorithm,
UnknownDeviceError,
} from "./base";
import { WITHHELD_MESSAGES } from '../OlmDevice';
import { IDecryptedGroupMessage, WITHHELD_MESSAGES } from '../OlmDevice';
import { Room } from '../../models/room';
import { DeviceInfo } from "../deviceinfo";
import { IOlmSessionResult } from "../olmlib";
@@ -1280,7 +1280,7 @@ class MegolmDecryption extends DecryptionAlgorithm {
// (fixes https://github.com/vector-im/element-web/issues/5001)
this.addEventToPendingList(event);
let res;
let res: IDecryptedGroupMessage;
try {
res = await this.olmDevice.decryptGroupMessage(
event.getRoomId(), content.sender_key, content.session_id, content.ciphertext,

View File

@@ -32,6 +32,7 @@ import {
import { Room } from '../../models/room';
import { MatrixEvent } from "../..";
import { IEventDecryptionResult } from "../index";
import { IInboundSession } from "../OlmDevice";
const DeviceVerification = DeviceInfo.DeviceVerification;
@@ -331,7 +332,7 @@ class OlmDecryption extends DecryptionAlgorithm {
// prekey message which doesn't match any existing sessions: make a new
// session.
let res;
let res: IInboundSession;
try {
res = await this.olmDevice.createInboundSession(
theirDeviceIdentityKey, message.type, message.body,

View File

@@ -323,7 +323,7 @@ export async function ensureOlmSessionsForDevices(
}
const oneTimeKeyAlgorithm = "signed_curve25519";
let res;
let res: IClaimOTKsResult;
let taskDetail = `one-time keys for ${devicesWithoutSession.length} devices`;
try {
log.debug(`Claiming ${taskDetail}`);

View File

@@ -823,18 +823,13 @@ export class MatrixEvent extends TypedEventEmitter<EmittedEvents, MatrixEventHan
//
if (this.retryDecryption) {
// decryption error, but we have a retry queued.
logger.log(
`Got error decrypting event (id=${this.getId()}: ` +
`${e}), but retrying`,
);
logger.log(`Got error decrypting event (id=${this.getId()}: ${e.detailedString}), but retrying`, e);
continue;
}
// decryption error, no retries queued. Warn about the error and
// set it to m.bad.encrypted.
logger.warn(
`Error decrypting event (id=${this.getId()}): ${e.detailedString}`,
);
logger.warn(`Got error decrypting event (id=${this.getId()}: ${e.detailedString})`, e);
res = this.badEncryptedMessage(e.message);
}