[BUG]: Non-Atomic Gap Log Writes Can Cause Data Loss After an Interrupted Save
I maintainer di solito rispondono entro 1 giorno
@SYED-IRTEZA-HUSSAIN-RIZVI ci sta già lavorando.
Dal 9/11/2026.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 74/100
Direzione di ricerca
Inizia in bot.py con _save_gap_log() e _load_gap_log(), poi verifica se il progetto include test per la persistenza del registro delle lacune. Riproduci un errore di scrittura dopo l’inizio del salvataggio e verifica che il registro esistente resti leggibile. L’issue è completata quando un salvataggio non riuscito conserva le voci valide precedenti e un salvataggio riuscito memorizza le voci aggiornate.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Bug Description
The _save_gap_log() function writes directly to gap_log.json using write mode ("w"). Opening the file in this mode truncates its existing contents before the new JSON data has been completely written.
If the process is interrupted, crashes, or encounters a write error during saving, the file may be left with incomplete or invalid JSON. When _load_gap_log() subsequently attempts to read the file, it catches json.JSONDecodeError and returns an empty list.
As a result, previously persisted gap-log entries may become inaccessible after an interrupted or failed save operation.
The save operation should use a safer file-writing strategy, such as writing the updated JSON data to a temporary file in the same directory and replacing the original file with os.replace() only after the temporary write completes successfully. This would help prevent an incomplete write from replacing the existing valid log.
This issue concerns data integrity and potential data loss caused by interrupted, non-atomic file writes. It is separate from the event-loop blocking issue tracked in [#57](https://github.com/AOSSIE-Org/SkillBot/issues/57).
Steps to Reproduce
- Set up SkillBot and ensure that
gap_log.jsonexists and contains valid JSON with multiple entries. - Start the bot and allow
_load_gap_log()to load the existing entries. - Trigger
_save_gap_log()with updated gap-log entries. - Observe that
_save_gap_log()opensgap_log.jsonusing write mode ("w"), which truncates the existing file. - Simulate a write failure after the original file has been truncated and some JSON content has been written. This can be done in a controlled test by mocking the serialization or write operation to raise an exception partway through.
- Inspect
gap_log.jsonand check whether it contains incomplete or invalid JSON. - Invoke
_load_gap_log()again or restart the bot. - Observe that the loader encounters a
json.JSONDecodeErrorand returns an empty list, potentially making the previously stored entries inaccessible.
Logs and Screenshots
No response
Environment Details
- Application: SkillBot Discord Bot
- Repository: AOSSIE-Org/SkillBot
- Operating System: Windows 11
- Python Version: 3.11.3
- Framework: asyncio
- Affected File:
bot.py - Affected Functions:
_save_gap_log()and_load_gap_log() - Affected File:
gap_log.json - Storage Format: JSON
- File Operation: Direct file writing using
open()with"w"mode - Relevant Exception:
json.JSONDecodeError - Affected Component: Persistent gap-log storage and recovery
Impact
Medium - Feature works but has issues
Code of Conduct
- I have joined the Discord server and will post updates there
- I have searched existing issues to avoid duplicates
- Lingua principale
- Python
- Stelle
- 10
- Fork
- 11
- Merge medio
- 6m
- PR unite (30g)
- 4
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di AOSSIE-Org/SkillBot
-
[BUG]: Issue-creation intent is missed when the article is omitted (create issue for this)Forse già presa @Ankitavasudev l’ha presa 8 giorni fa. Apertabug enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
AOSSIE-Org/SkillBot#65 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG]: os.chdir() Changes the Process-Wide Working Directory During Repository SyncForse già presa @aadityachhipa80-oss l’ha presa 2 giorni fa. Apertabug enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
AOSSIE-Org/SkillBot#59 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG]: wait_for_ollama() Retries Indefinitely When Ollama Is UnavailableForse di nuovo libera @SYED-IRTEZA-HUSSAIN-RIZVI l’ha presa 11 giorni fa e non c’è nessuna pull request aperta. Apertabug enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
AOSSIE-Org/SkillBot#56 · 3 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG]: Backlog Messages Are Re-processed on Discord ReconnectionForse di nuovo libera @SYED-IRTEZA-HUSSAIN-RIZVI l’ha presa 11 giorni fa e non c’è nessuna pull request aperta. Apertabug enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
AOSSIE-Org/SkillBot#58 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
[BUG]: _log_gap() Performs Blocking File I/O on the Async Event LoopForse già presa @abu-tahir-0 l’ha presa 13 giorni fa. Apertabug enhancement
Difficoltà 3/5 1-2 giorni Idoneità per principianti 25/100
AOSSIE-Org/SkillBot#57 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di AOSSIE-Org/SkillBot
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
I maintainer di solito rispondono entro 1 giorno
-
Unused loot bag group names left in dreamcraft en_US.langForse già presa Una pull request collegata a questa issue è aperta o già unita. ApertaStatus: Triage Suggestion
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
GTNewHorizons/GT-New-Horizons-Modpack#27789 ·
I maintainer di solito rispondono entro 1 giorno
-
bug frontend sev-5
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
-
core good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
b4b code health next
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
ESCOMP/CTSM#4330 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno