Skip to content

PUT /api/v1/events creates a new event on every call, so a retried request duplicates it #268

Open

Description

@lumenpearson

PUT /api/v1/events (server/app/api/edit.py:409, event_put) inserts a new DayEvent on every call and answers 201. Its docstring says why: events have no natural key — two «Обед» rows on one day are two breaks — so it always creates.

The reason is real; the method is wrong for it. PUT is idempotent by definition, so a client, a proxy or a retrying HTTP library may resend it after a timeout, and every resend here is a second event, a second audit line and a second announcement in the class chat.

Failure scenario. An editor's phone sends PUT /api/v1/events with «Экскурсия», 14:00–16:00; the response is lost to a dropped connection after the commit; OkHttp (or the user) retries. The class now has two identical «Экскурсия» events, the journal records two additions, and every member gets «📅 Событие: Экскурсия» twice.

No current APK calls this route (found by the API survey of 3 October 2026), so nobody has hit it yet.

Where it goes. The v2 contract makes creation a POST on class/events (docs/specs/2026-10-03-one-contract-design.md, the resource map), so a retry can be told apart; v1, and this route with it, is then removed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status
      Ready

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions