Skip to content

Sync engine: first board sync after login fails with 500 on PUT /communicator/:id #2203

@RodriSanchez1

Description

@RodriSanchez1

Description

After logging in with an account that has no communicator and no boards on the server, doing the first board sync with two or more local boards pending fails with 500 Internal Server Error on PUT /communicator/:id.

The first board push succeeds (POST /communicator). The second board push then issues a PUT with a payload that still carries the default communicator fields (email: 'support@cboard.io', author: 'Cboard Team') instead of the user's data, which the server rejects.

Steps to reproduce

  1. Create an account that has no communicator nor boards on the server.
  2. Before logging in, have at least two local boards pending sync (e.g. created while unlogged or modified default boards).
  3. Log in and let the sync engine run (getApiObjectssyncBoardspushLocalChangesToApi).
  4. Observe Network tab: first POST /communicator returns 200, second PUT /communicator/:id returns 500.

Root cause

pushLocalChangesToApi in src/components/Board/Board.actions.js calls updateApiObjectsNoChild for each board needing creation. That helper ends with upsertApiCommunicator(comm):

  • First call: comm.id === 'cboard_default' → goes through createApiCommunicator (POST). api.js strips the id and overrides email / author with the user's data, so the POST succeeds.
  • The CREATE_API_COMMUNICATOR_SUCCESS reducer only copies id and lastEdited from the response, leaving email and author as the default values locally.
  • Second call: comm.id is now the Mongo id from the server → goes through updateApiCommunicator (PUT). The PUT body is sent verbatim, still carrying email: 'support@cboard.io' and author: 'Cboard Team' → server returns 500.

The rest of the app (CommunicatorDialog: copyBoard, setRootBoard, deleteMyBoard, board reorder) avoids this by calling verifyAndUpsertCommunicator before any communicator push, which forks the default communicator to one owned by the user (new shortid + user's email / author). The new sync engine path bypasses this step.

Expected behavior

The sync engine should follow the same invariant as the rest of the app: before pushing the active communicator to the API, ensure it has been forked from the default if it still belongs to support@cboard.io.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions