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

Element-R | "Unable to set up keys" error on register #26755

Closed
BillCarsonFr opened this issue Dec 13, 2023 · 6 comments · Fixed by matrix-org/matrix-js-sdk#4061
Closed

Element-R | "Unable to set up keys" error on register #26755

BillCarsonFr opened this issue Dec 13, 2023 · 6 comments · Fixed by matrix-org/matrix-js-sdk#4061
Assignees
Labels
A-Element-R Issues affecting the port of Element's crypto layer to Rust O-Occasional Affects or can be seen by some users regularly or most users rarely S-Minor Impairs non-critical functionality or suitable workarounds exist

Comments

@BillCarsonFr
Copy link
Member

Step to reproduce

  1. Create a new account on develop against matrix.org

Actual

image image

=> click on retry fixes it

@BillCarsonFr BillCarsonFr added the A-Element-R Issues affecting the port of Element's crypto layer to Rust label Dec 13, 2023
@BillCarsonFr BillCarsonFr added the Z-Element-R-Blocker A blocker for enabling Element R by default label Dec 13, 2023
@BillCarsonFr
Copy link
Member Author

Typing console for search: Secret storage is not yet set up; not exporting keys to secret storage yet.

2023-12-13T09:53:16.364Z E Error bootstrapping cross-signing MatrixError: [500] Internal server error (https://matrix-client.matrix.org/_matrix/client/v3/keys/upload)
M_UNKNOWN: MatrixError: [500] Internal server error (https://matrix-client.matrix.org/_matrix/client/v3/keys/upload)
    at parseErrorResponse (https://develop.element.io/bundles/faa9a7c9e9ac7ec05a84/bundle.js:126805:12)
    at MatrixHttpApi.requestOtherUrl (https://develop.element.io/bundles/faa9a7c9e9ac7ec05a84/bundle.js:127155:13)
    at async MatrixHttpApi.authedRequest (https://develop.element.io/bundles/faa9a7c9e9ac7ec05a84/bundle.js:126996:24)
    at async OutgoingRequestProcessor.rawJsonRequest (https://develop.element.io/bundles/faa9a7c9e9ac7ec05a84/4977.js:408:12)
    at async OutgoingRequestProcessor.makeOutgoingRequest (https://develop.element.io/bundles/faa9a7c9e9ac7ec05a84/4977.js:322:14)
    at async CrossSigningIdentity.resetCrossSigning (https://develop.element.io/bundles/faa9a7c9e9ac7ec05a84/4977.js:730:9)
    at async CrossSigningIdentity.bootstrapCrossSigning (https://develop.element.io/bundles/faa9a7c9e9ac7ec05a84/4977.js:695:9)
    at async RustCrypto.bootstrapCrossSigning (https://develop.element.io/bundles/faa9a7c9e9ac7ec05a84/4977.js:3114:5)

@richvdh
Copy link
Member

richvdh commented Dec 13, 2023

(I think the resetCrossSigning: Secret storage is not yet set up; not exporting keys to secret storage yet warning might be a red herring here)

@richvdh
Copy link
Member

richvdh commented Dec 13, 2023

Server-side logs for that request:

psycopg2.errors.UniqueViolation: duplicate key value violates unique constraint "e2e_one_time_keys_json_uniqueness"
DETAIL:  Key (user_id, device_id, algorithm, key_id)=(@valere_backup:matrix.org, SETMVBAUQK, signed_curve25519, AAAAAAAAAA0) already exists.

The server is supposed to ignore attempts to re-upload the same key twice; however if the two requests happen very close together they can race, producing a 500.

Looking at the client-side logs, it looks like we're making two /keys/upload requests at once, without waiting for the response:

2023-12-13T09:53:16.154Z D FetchHttpApi: --> POST https://matrix-client.matrix.org/_matrix/client/v3/keys/upload
2023-12-13T09:53:16.172Z W resetCrossSigning: Secret storage is not yet set up; not exporting keys to secret storage yet.
2023-12-13T09:53:16.172Z D resetCrossSigning: publishing keys to server
2023-12-13T09:53:16.172Z D FetchHttpApi: --> POST https://matrix-client.matrix.org/_matrix/client/v3/keys/upload
...
2023-12-13T09:53:16.363Z D FetchHttpApi: <-- POST https://matrix-client.matrix.org/_matrix/client/v3/keys/upload [190ms 500]
2023-12-13T09:53:16.364Z E Error bootstrapping cross-signing MatrixError: [500] Internal server error (https://matrix-client.matrix.org/_matrix/client/v3/keys/upload)
...
2023-12-13T09:53:16.404Z D FetchHttpApi: <-- POST https://matrix-client.matrix.org/_matrix/client/v3/keys/upload [250ms 200]

One request succeeds, and the other fails.

I think we should find out why we are making two /upload requests at once and fix it.

@richvdh richvdh changed the title Element-R | Setting Up key error on register Element-R | "Unable to set up keys" error on register Dec 13, 2023
@richvdh
Copy link
Member

richvdh commented Dec 13, 2023

(presumably this is because OlmMachine::bootstrap_cross_signing returns an UploadKeysRequest, in addition to the one that OlmMachine::outgoing_requests has already returned.)

@richvdh
Copy link
Member

richvdh commented Dec 13, 2023

An alternative would be just to retry the request on a 500 error. That's something we ought to do anyway, really.

@MidhunSureshR MidhunSureshR added S-Major Severely degrades major functionality or product features, with no satisfactory workaround O-Occasional Affects or can be seen by some users regularly or most users rarely labels Dec 18, 2023
@richvdh
Copy link
Member

richvdh commented Dec 20, 2023

This also causes intermittent errors in the Playwright tests. For example: https://e2e-12054--matrix-react-sdk.netlify.app/#?testId=629a0fc9a6da9f9a3754-1d0b117813dd9b94cd4f038c2392796d4a22

Error: page.evaluateHandle: M_UNKNOWN: MatrixError: [500] Internal server error (http://localhost:38339/_matrix/client/v3/keys/upload)

    at parseErrorResponse (http://localhost:8080/bundles/c12149197beaa7e38caa/bundle.js:33292:12)
    at MatrixHttpApi.requestOtherUrl (http://localhost:8080/bundles/c12149197beaa7e38caa/bundle.js:33642:13)
    at async MatrixHttpApi.authedRequest (http://localhost:8080/bundles/c12149197beaa7e38caa/bundle.js:33483:24)
    at async OutgoingRequestProcessor.rawJsonRequest (http://localhost:8080/bundles/c12149197beaa7e38caa/2606.js:436:12)
    at async OutgoingRequestProcessor.makeOutgoingRequest (http://localhost:8080/bundles/c12149197beaa7e38caa/2606.js:346:14)
    at async CrossSigningIdentity.resetCrossSigning (http://localhost:8080/bundles/c12149197beaa7e38caa/2606.js:756:9)
    at async CrossSigningIdentity.bootstrapCrossSigning (http://localhost:8080/bundles/c12149197beaa7e38caa/2606.js:721:9)
    at async RustCrypto.bootstrapCrossSigning (http://localhost:8080/bundles/c12149197beaa7e38caa/2606.js:3145:5)
    at async eval (eval at evaluate (:226:30), <anonymous>:82:9)
    at parseErrorResponse (/home/runner/work/matrix-react-sdk/matrix-react-sdk/matrix-react-sdk/http:/localhost:8080/bundles/c12149197beaa7e38caa/bundle.js:33292:12)
    at MatrixHttpApi.requestOtherUrl (/home/runner/work/matrix-react-sdk/matrix-react-sdk/matrix-react-sdk/http:/localhost:8080/bundles/c12149197beaa7e38caa/bundle.js:33642:13)
    at async MatrixHttpApi.authedRequest (/home/runner/work/matrix-react-sdk/matrix-react-sdk/matrix-react-sdk/http:/localhost:8080/bundles/c12149197beaa7e38caa/bundle.js:33483:24)
    at async OutgoingRequestProcessor.rawJsonRequest (/home/runner/work/matrix-react-sdk/matrix-react-sdk/matrix-react-sdk/http:/localhost:8080/bundles/c12149197beaa7e38caa/2606.js:436:12)
    at async OutgoingRequestProcessor.makeOutgoingRequest (/home/runner/work/matrix-react-sdk/matrix-react-sdk/matrix-react-sdk/http:/localhost:8080/bundles/c12149197beaa7e38caa/2606.js:346:14)
    at async CrossSigningIdentity.resetCrossSigning (/home/runner/work/matrix-react-sdk/matrix-react-sdk/matrix-react-sdk/http:/localhost:8080/bundles/c12149197beaa7e38caa/2606.js:756:9)
    at async CrossSigningIdentity.bootstrapCrossSigning (/home/runner/work/matrix-react-sdk/matrix-react-sdk/matrix-react-sdk/http:/localhost:8080/bundles/c12149197beaa7e38caa/2606.js:721:9)
    at async RustCrypto.bootstrapCrossSigning (/home/runner/work/matrix-react-sdk/matrix-react-sdk/matrix-react-sdk/http:/localhost:8080/bundles/c12149197beaa7e38caa/2606.js:3145:5)
    at async eval (/home/runner/work/matrix-react-sdk/matrix-react-sdk/matrix-react-sdk/eval at evaluate (:226:30), <anonymous>:82:9)
    at Bot.getClientHandle (/home/runner/work/matrix-react-sdk/matrix-react-sdk/matrix-react-sdk/playwright/pages/bot.ts:103:40)
    at Bot.prepareClient (/home/runner/work/matrix-react-sdk/matrix-react-sdk/matrix-react-sdk/playwright/pages/client.ts:47:27)
    at /home/runner/work/matrix-react-sdk/matrix-react-sdk/matrix-react-sdk/playwright/e2e/crypto/verification.spec.ts:52:9

(NB: although that is test for "legacy crypto", this is a failure to set up the "bot" user, which always uses Rust Crypto in this test.)

@BillCarsonFr BillCarsonFr added S-Minor Impairs non-critical functionality or suitable workarounds exist and removed S-Major Severely degrades major functionality or product features, with no satisfactory workaround Z-Element-R-Blocker A blocker for enabling Element R by default labels Jan 12, 2024
@github-actions github-actions bot added Z-Labs and removed Z-Labs labels Jan 12, 2024
@BillCarsonFr BillCarsonFr self-assigned this Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Element-R Issues affecting the port of Element's crypto layer to Rust O-Occasional Affects or can be seen by some users regularly or most users rarely S-Minor Impairs non-critical functionality or suitable workarounds exist
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants