Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Data Inconsistency When Editing Task (Missing Transaction)

Aperta
#643 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
52/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
dart, flutter

Direzione di ricerca

Inizia in task_database.dart da saveEditedTaskInDB(), poi esamina setTagsForTask() e getTaskByUuid() per comprendere gli attuali confini del database. Riproduci una modifica che coinvolga i campi dell'attività e i tag, inclusa un'interruzione tra le operazioni. Il lavoro è completo quando le modifiche all'attività e ai tag hanno entrambe esito positivo oppure nessuna delle due viene resa persistente, senza accessi annidati al database o accessi al database al di fuori della transazione.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug
Describe your issue

When editing a task using saveEditedTaskInDB() in task_database.dart, the task details and associated tags are updated using separate database operations without a single transaction.

This can lead to data inconsistency if the app crashes or an error occurs between the task update and tag update operations.

As a result:

Task fields (description, project, etc.) may update successfully
Tags may remain stale or partially updated

This violates atomicity and can reduce user trust in data integrity.****

Steps to reproduce

Open the app and navigate to any existing task
Edit the task (change description and tags)
Trigger a failure between operations (e.g., force close app after task update but before tag update)
Restart the app and fetch the task

What was the expected result?

No response

Put here any screenshots or videos (optional)

No response

How can we contact you (optional)

Task update and tag update should be atomic
Either both updates succeed, or none are applied
No partial or inconsistent state should exist
Actual behavior
Task is updated successfully
Tags remain unchanged or partially updated
Database enters inconsistent state
Root cause

In saveEditedTaskInDB():

await _database!.update('Tasks', {...});

if (newTags.isNotEmpty) {
TaskForC? task = await getTaskByUuid(uuid);
await setTagsForTask(uuid, task?.id ?? 0, newTags.toList());
}
Multiple DB operations are executed outside a transaction
setTagsForTask() internally uses a separate transaction
getTaskByUuid() reads using _database, not transaction context
Proposed fix

Wrap all operations in a single database transaction and avoid nested transactions:

await _database!.transaction((txn) async {
await txn.update(...);

final taskMaps = await txn.query(...);
final taskId = taskMaps.first['id'];

await txn.delete(...);

for (String tag in newTags) {
await txn.insert(...);
}
});
Additional notes
Avoid calling _database inside a transaction → use txn
Avoid nested transactions (setTagsForTask() should accept txn)
Consider enforcing PRAGMA foreign_keys = ON for relational integrity
Impact
Data inconsistency
Partial updates
Poor user experience
Suggested priority

High – affects core data integrity

Would you like to work on this issue?

Yes

By submitting this issue, I have confirmed that:
  • I have starred the repo ⭐ and watched 👀 it on GitHub and followed the contribution guidelines.
Lingua principale
Dart
Stelle
244
Fork
179
Merge medio
12h 42m
PR unite (30g)
2

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di CCExtractor/taskwarrior-flutter

Tutte le issue di CCExtractor/taskwarrior-flutter

Issue simili

Altre issue su Dart

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.