Data Inconsistency When Editing Task (Missing Transaction)
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 52/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Quiet
- Tech stack
- dart, flutter
- Domain
- databases, mobile-dev
Research direction
Start in task_database.dart at saveEditedTaskInDB(), then inspect setTagsForTask() and getTaskByUuid() to understand the current database boundaries. Reproduce an edit involving task fields and tags, including an interruption between operations. Done means task and tag changes succeed together or neither is persisted, without nested or out-of-transaction database access.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Dart
- Stars
- 244
- Forks
- 179
- Avg merge
- 12h 42m
- Merged PRs (30d)
- 2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from CCExtractor/taskwarrior-flutter
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
CCExtractor/taskwarrior-flutter#639 · 2 comments ·
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 4/5 3-5 days Newbie friendliness 30/100
CCExtractor/taskwarrior-flutter#647 · 1 reaction ·
-
bug
Difficulty 5/5 Over a week Newbie friendliness 45/100
CCExtractor/taskwarrior-flutter#645 · 1 comment ·
All issues in CCExtractor/taskwarrior-flutter
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
flutter-webrtc/flutter-webrtc#2206 ·
-
from.page-issue
Difficulty 1/5 Under an hour Newbie friendliness 85/100
-
triage
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
[Super Editor][Chat] - Floating editor scaffold does not reset panel height after closing panel Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
status: needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
a2ui-project/a2ui#2763 ·