Skip to content

fix(api): run one privacy export per account at a time - #1007

Open
Medformatik wants to merge 2 commits into
fix/csp-on-every-pagefrom
fix/privacy-export-admission
Open

Medformatik wants to merge 2 commits into
fix/csp-on-every-pagefrom
fix/privacy-export-admission

Conversation

@Medformatik

@Medformatik Medformatik commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

What changed and why

The self-service privacy export collects an account's data across the database and connected sources and streams it as an archive. It required a recent sign-in but had no limit on how many exports one account could run at once, and it sat in the broad rate-limit class. One signed-in account could keep many full export preparations running.

An account now holds one export slot at a time, and the API process runs at most four exports in total. A second export for the same account is refused with 409 EXPORT_IN_PROGRESS before anything is recorded; at the process limit the answer is 503 PRIVACY_SERVICE_UNAVAILABLE. The slot is released after a finished download, a failed preparation and an interrupted stream, and only once the outcome has been recorded, so retrying an interrupted download works as before. The route also moves to the expensive rate-limit class. The web app shows a specific message for both refusals.

If the client leaves while the export is still being prepared, the archive stream now ends at once. A download also ends after 60 seconds in which the client takes no data and after one hour in total, so a slow or stalled reader cannot keep a slot; the administrator-led download uses the same stream and gets the same limits. Collecting the managed timeline stops when the client leaves or after 20 minutes. Collecting from the OpenMapX database has no deadline of its own yet.

The slots live in the API process, like the other rate limits; with several replicas each one counts its own. The administrator-led export is unchanged: each of those needs a one-time re-authentication.

Related work

Eighth layer of the stack that starts with #983.

Verification

  • Focused tests pass (122 tests): a new route test for the slot (second concurrent export refused, slot free after success, after a failed preparation, after an abort mid-stream and during preparation, another account not blocked), tests for the early-disconnect path and both time limits, the rate-limit class table and the web message cases.
  • check-types passes for apps/api, packages/core and apps/web; Biome, Prettier, check-translations and check-openapi pass.
  • Not run locally: the database-backed export tests, left to CI. Not done: a check of the new messages in a browser.

Release and upgrade impact

No operator action and no migration.

No package release: the extension CLI is counted through shared core and translation sources, but it uses neither the privacy error codes nor the strings added here.

@Medformatik Medformatik self-assigned this Nov 16, 2026
@Medformatik
Medformatik added this pull request to stack #985 November 16, 2026 09:42
@Medformatik
Medformatik force-pushed the fix/privacy-export-admission branch from a23a70d to 14f9fa8 Compare November 16, 2026 10:00
Any number of exports for one account could be prepared and streamed at
once. An account now holds one export slot, the process allows four in
total, and the route joins the expensive rate-limit class. A retry after an
interrupted download is accepted once the earlier attempt has settled.
An export slot was held until the stream settled, with no limit on how long
that could take. The download now ends after 60 seconds without the client
taking data and after one hour in total, and collecting the managed timeline
stops when the client leaves or after 20 minutes.
@Medformatik
Medformatik force-pushed the fix/privacy-export-admission branch from 14f9fa8 to 7886784 Compare November 16, 2026 17:23
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