Consider atomic JSON writes

Open Beginner friendly
#412 3 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 3 days

@ashiishe2-oss is already working on this.

Since Nov 7, 2026.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
70/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
fastapi, json, python
Domain
backend, databases

Research direction

Find the code that writes Thing settings and read how it currently serializes and saves the JSON file. Then check the project’s existing tests for settings persistence and add coverage for interrupted or atomic writes. Done means a settings update uses a temporary file and replacement so the settings file remains valid if writing is interrupted.

Written by the indexing model from the issue text.

Description

Describe the bug
If LabThings is interrupted while writing Thing settings, the file could get corrupted.

To Reproduce
Pull the power during a settings update.

Expected behaviour
It would be nice if the file didn't get corrupted.

Additional context
This should be easy enough to avoid by writing to a temp file, then swapping the temp file with the actual settings file. That reduces to nearly-zero the time during which the file could be broken.

Dominant language
Python
Stars
10
Forks
4
Avg merge
4d 15h
Merged PRs (30d)
11

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from labthings/labthings-fastapi

All issues in labthings/labthings-fastapi

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.