In nanobot/channels/matrix.py, the matrix-nio client (AsyncClient) performs an E2E sync with Conduit (a lightweight Matrix server) but fails with SyncError: M_UNKNOWN_TOKEN and the error message 'one_time_key_counts' is a required property.
Manual sync via curl works perfectly:
curl GET /_matrix/client/v3/sync using the same token → responds correctly.
The problem arises because when matrix-nio is used with encryption_enabled=True, it expects an E2E sync response that Conduit does not handle strictly according to the library's requirements. Specifically, the one_time_key_counts field is missing from the response, causing matrix-nio to invalidate the token.
Requested Fix:
Modify matrix.py so the AsyncClient is configured with AsyncClientConfig(store_sync_tokens=True, encryption_enabled=True), while implementing a patch or workaround to handle the missing one_time_key_counts field in the sync response.
The fix should:
Intercept the sync response.
Default one_time_key_counts to an empty dictionary {} if the field is absent.
Ensure E2E encryption remains enabled while maintaining compatibility with Conduit.
In nanobot/channels/matrix.py, the matrix-nio client (AsyncClient) performs an E2E sync with Conduit (a lightweight Matrix server) but fails with SyncError: M_UNKNOWN_TOKEN and the error message 'one_time_key_counts' is a required property.
Manual sync via curl works perfectly:
curl GET /_matrix/client/v3/sync using the same token → responds correctly.
The problem arises because when matrix-nio is used with encryption_enabled=True, it expects an E2E sync response that Conduit does not handle strictly according to the library's requirements. Specifically, the one_time_key_counts field is missing from the response, causing matrix-nio to invalidate the token.
Requested Fix:
Modify matrix.py so the AsyncClient is configured with AsyncClientConfig(store_sync_tokens=True, encryption_enabled=True), while implementing a patch or workaround to handle the missing one_time_key_counts field in the sync response.
The fix should:
Intercept the sync response.
Default one_time_key_counts to an empty dictionary {} if the field is absent.
Ensure E2E encryption remains enabled while maintaining compatibility with Conduit.