Skip to content

core, python: fix refused renames, extend the client API - #7379

Open
shumvgolove wants to merge 8 commits into
masterfrom
sh/core-fixes
Open

core, python: fix refused renames, extend the client API#7379
shumvgolove wants to merge 8 commits into
masterfrom
sh/core-fixes

Conversation

@shumvgolove

@shumvgolove shumvgolove commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Core

1: Rejecting a duplicate name corrupts the database

Display names are unique. When a rename hits an existing name, the core reports the error but keeps part of the write: the user row ends up holding a name that belongs to another contact, while that contact and the group member rows keep the old one. Nothing can repair it through the API. Creating a user with a taken name has the same problem and leaves the database with no active user.

Both now write the name first, so a rejected change writes nothing at all. Query plans are regenerated for the new statement.

2: The message batch limit does not compile on GHC 8.10

The helper added in #7364 (lengthLE in Simplex.Chat.Protocol) is defined in infix form with a bang pattern, which GHC 9.0 and later accept but GHC 8.10 rejects with a parse error. The library therefore builds on the current compiler but not on the oldest supported one.

Python library

1: Starting a client crashes

start_chat did not set serviceRequests, a field the generated command string reads, so every start raised KeyError. api_reject_contact_request did not set notify.

2: Ctrl+C during startup is ignored

Startup runs database migrations and creates the address, which takes a few seconds. A signal in that window was dropped and the client started serving anyway. The stop is now remembered, Client.stop_requested reports it, and Client.install_signal_handlers() lets a caller install the handlers before startup rather than after.

3: The profile cannot be changed after start

The profile was applied while the client started, so it could not contain anything that depends on reading the database first. Client.profile and Client.sync_profile() apply it once the client is running.

4: The avatar can be set to a format no app displays

The core stores any value starting with data:, but every client decodes only data:image/png;base64, and data:image/jpg;base64,
(Images.android.kt, Images.desktop.kt, ImageUtils.swift). They strip those two prefixes rather than check them, so an image in any other format is passed to the base64 decoder unchanged, fails to decode, and shows as an empty avatar to every contact.

The profile is now checked before it is sent, and util.check_profile_image exposes the same check to callers that build the data URI themselves.

5: Common operations have no API

  • ChatError: one base class for the two exceptions raised for the same kind of failure.
  • ChatAPIError.error_type, .store_error_type, .command_error: the error tags and the message, until now read out of the raw chat_error dictionary by every caller.
  • ChatApi.api_accept_member_contact, api_merge_{contact,group}_custom_data, util.merged_custom_data, util.conn_status.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant