Fix dataset sidecar write race condition, duplicate app init, and missing status/priority persistence#40
Draft
ShockaHolmes with Copilot wants to merge 2 commits into
Draft
Fix dataset sidecar write race condition, duplicate app init, and missing status/priority persistence#40ShockaHolmes with Copilot wants to merge 2 commits into
ShockaHolmes with Copilot wants to merge 2 commits into
Conversation
Closed
…sing status/priority persistence Agent-Logs-Url: https://github.com/ShockaHolmes/NoteForge/sessions/e9ec2f6f-5fda-4cc1-bf20-6305c085016a Co-authored-by: ShockaHolmes <78627489+ShockaHolmes@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Test app functionality and fix identified bugs
Fix dataset sidecar write race condition, duplicate app init, and missing status/priority persistence
Apr 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Running the app under test revealed three bugs in the dataset pipeline: a race condition causing random 404s, a duplicate FastAPI app instantiation, and
status/priorityfields being silently dropped on every save.Race condition in sidecar writes
_PROFILE_EXECUTORbackground threads rewrote sidecar files viaPath.write_text(), which truncates before writing. A concurrent read between truncation and completion would see an empty file, causingparse_sidecar("")→ id"untitled"→get_by_idreturningNone→ HTTP 404. Failures were non-deterministic and affected different tests each run.Fixed by adding
_write_text_atomic()— writes to a temp file in the same directory thenos.replace()(atomic on POSIX) — applied to all three sidecar write sites:save(),save_with_file(), andsave_profile().Duplicate
app = create_app()inapp.pyModule-level
create_app()was called twice, discarding the first instance. Removed the duplicate.DatasetMetadatamissingstatusandpriorityDatasetMetadata(the YAML serialization layer) omitted these fields, silently dropping them on everysave(). APATCHupdating status/priority would appear successful but return stale values on the nextGET. Added both fields toDatasetMetadata.from_dataset(),to_dataset(),to_dict(), andfrom_dict().