Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: How to send encrypted custom events? #209

Closed
jaller94 opened this issue Apr 26, 2022 · 4 comments · Fixed by #236
Closed

Question: How to send encrypted custom events? #209

jaller94 opened this issue Apr 26, 2022 · 4 comments · Fixed by #236
Assignees
Labels
bug Something isn't working e2ee Issue relating to encryption

Comments

@jaller94
Copy link
Contributor

jaller94 commented Apr 26, 2022

I'm trying to send encrypted events, but only standard messages are successfully sent. Not custom events like this:

client.sendEvent(roomId, 'org.matrix.msc3672.beacon', {
    "m.relates_to": { // from MSC2674: https://github.com/matrix-org/matrix-doc/pull/2674
        "rel_type": "m.reference", // from MSC3267: https://github.com/matrix-org/matrix-doc/pull/3267
        "event_id": beaconEventId,
    },
    "org.matrix.msc3488.location": {
        uri: lastPosition.geo,
        // description: "Arbitrary beacon information"
    },
    "org.matrix.msc3488.ts": Date.parse(lastPosition.date),
});

I get the following error:

thread '<unnamed>' panicked at 'Encrypting an event produced an error: JsonError(Error("Failed to serialize event [content] enum: Unknown event type.\nTo send custom events, turn them into `Raw<EnumType>` by going through\n         `serde_json::value::to_raw_value` and `Raw::from_json`.", line: 0, column: 0))', crates/matrix-sdk-crypto-nodejs/src/machine.rs:330:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5
./run.sh: line 10: 52386 Aborted                 (core dumped) npx ts-node src/index.ts

I've tried to make content safe by wrapping it like this: JSON.stringify(content) and JSON.parse(JSON.stringify(content)).
However, so far nothing change the error.

Full backtrace:

stack backtrace:
   0:     0x7f13da7e9c0c - std::backtrace_rs::backtrace::libunwind::trace::hf6a6dfd7da937cb0
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x7f13da7e9c0c - std::backtrace_rs::backtrace::trace_unsynchronized::hc596a19e4891f7f3
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x7f13da7e9c0c - std::sys_common::backtrace::_print_fmt::hb16700db31584325
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x7f13da7e9c0c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h231c4190cfa75162
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x7f13da80b98c - core::fmt::write::h2a1462b5f8eea807
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/fmt/mod.rs:1163:17
   5:     0x7f13da7e5f55 - std::io::Write::write_fmt::h71ddfebc68685972
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/io/mod.rs:1696:15
   6:     0x7f13da7ebc50 - std::sys_common::backtrace::_print::hcc197d4bebf2b369
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x7f13da7ebc50 - std::sys_common::backtrace::print::h335a66af06738c7c
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x7f13da7ebc50 - std::panicking::default_hook::{{closure}}::h6fac9ac9c8b79e52
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:210:50
   9:     0x7f13da7eb805 - std::panicking::default_hook::h341c1030c6a1161b
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:227:9
  10:     0x7f13da7ec304 - std::panicking::rust_panic_with_hook::h50680ff4b44510c6
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:624:17
  11:     0x7f13da7ebde0 - std::panicking::begin_panic_handler::{{closure}}::h9371c0fbb1e8465a
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:521:13
  12:     0x7f13da7ea0b4 - std::sys_common::backtrace::__rust_end_short_backtrace::h9b3efa22a5768c0f
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/sys_common/backtrace.rs:139:18
  13:     0x7f13da7ebd49 - rust_begin_unwind
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/std/src/panicking.rs:517:5
  14:     0x7f13da24e111 - core::panicking::panic_fmt::h23b9203e89cc61cf
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/panicking.rs:100:14
  15:     0x7f13da24e203 - core::result::unwrap_failed::h32ef6b3156e8fc57
                               at /rustc/f1edd0429582dd29cccacaf50fd134b05593bd9c/library/core/src/result.rs:1616:5
  16:     0x7f13da4e24b6 - matrix_sdk_crypto_nodejs::machine::SledBackedOlmMachine::encrypt::he8a188746506b670
  17:     0x7f13da4742bb - matrix_sdk_crypto_nodejs::machine::__napi_impl_helper__SledBackedOlmMachine__0::__napi__encrypt::h5de657e7345939cf
  18:           0xb01add - _ZN6v8impl12_GLOBAL__N_123FunctionCallbackWrapper6InvokeERKN2v820FunctionCallbackInfoINS2_5ValueEEE
  19:           0xda4a70 - _ZN2v88internal12_GLOBAL__N_119HandleApiCallHelperILb0EEENS0_11MaybeHandleINS0_6ObjectEEEPNS0_7IsolateENS0_6HandleINS0_10HeapObjectEEESA_NS8_INS0_20FunctionTemplateInfoEEENS8_IS4_EENS0_16BuiltinArgumentsE
  20:           0xda600f - _ZN2v88internal21Builtin_HandleApiCallEiPmPNS0_7IsolateE
  21:          0x16d8639 - Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_BuiltinExit
fatal runtime error: failed to initiate panic, error 5
@turt2live
Copy link
Owner

arg, this looks like ruma being slightly awkward to work with.

@jaller94
Copy link
Contributor Author

jaller94 commented May 3, 2022

Affects:

  • 0.6.0-beta.7 and likely previous versions
  • 0.6.0-beta.8

@turt2live
Copy link
Owner

it'll affect all 0.6.0 versions until the bindings are fixed. There is no timeline on that at present.

@turt2live turt2live added bug Something isn't working e2ee Issue relating to encryption labels May 30, 2022
@turt2live
Copy link
Owner

This will be fixed by new bindings: #236

@turt2live turt2live self-assigned this Jul 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working e2ee Issue relating to encryption
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants