matrix-org / matrix-org/matrix-rust-sdk

`ConstraintError` when trying to request secrets

Open
#6,518 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
2.3k
Forks
500
Avg merge
1d 16h
Merged PRs (30d)
106

Description

This issue comes from a rageshake, but it isn't entirely clear how the cilent got into this situation.

The user tried to self-verify, and the verification succeeded, which resulted in the new client requesting secrets from the old client. However, when it does so, it encounters a `ConstraintError` when trying to store the secret request:

```
2026-04-07T17:04:40.605Z I INFO matrix_sdk_crypto::gossiping::machine: Creating new outgoing secret requests
secret_names=["m.cross_signing.master", "m.cross_signing.self_signing"]
at /home/runner/.cargo/git/checkouts/matrix-rust-sdk-5cafb5792f78b8d1/8472b55/crates/matrix-sdk-crypto/src/gossiping/machine.rs:765
in matrix_sdk_crypto::verification::machine::receive_any_event with flow_id="fd54ebe708494ffaa2cde546d0e6a5e0"
in matrix_sdk_crypto::machine::receive_to_device_event with sender="@----:----" event_type="m.key.verification.done"
in matrix_sdk_crypto::machine::receive_sync_changes
2026-04-07T17:04:40.606Z E ERROR matrix_sdk_crypto::machine: Error handling a verification event: Backend(DomException { code: 0, name: "ConstraintError", message: "Unable to add key to index 'by_info': at least one key does not satisfy the uniqueness requirements." })
at /home/runner/.cargo/git/checkouts/matrix-rust-sdk-5cafb5792f78b8d1/8472b55/crates/matrix-sdk-crypto/src/machine/mod.rs:1422
in matrix_sdk_crypto::machine::receive_to_device_event with sender="@----:----" event_type="m.key.verification.done"
in matrix_sdk_crypto::machine::receive_sync_changes
```

(The `by_info` index seems to just be the secret name for secret requests.)

It's also suspicious that it's only requesting the master and self-signing keys, and not the user-signing key.

From the logs, it looks like this is the first time that secrets are requested, so there shouldn't be any other records in the store that would cause the constraint to fail.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing secret-request creation at crates/matrix-sdk-crypto/src/gossiping/machine.rs:765 and the error path at crates/matrix-sdk-crypto/src/machine/mod.rs:1422. Investigate how the by_info uniqueness constraint can fail during self-verification, including why only the master and self-signing keys are requested; done means identifying the cause and preventing the erroneous ConstraintError.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.