fix: resolve file deletion conflict, empty paths, timestamp comparison and event mutation (#149) - #151
Open
ranadheer-designs wants to merge 1 commit into
Conversation
…n and event mutation (tscircuit#149)
Author
|
cc @seveibar @looternikhil-cpu (issue author) All CI checks are passing (3/3 green). Fixes #149 covering the 4 consistency fixes (delete selector conflict handling, empty path validation, timestamp parsing with timezones, and event snapshot immutability) with dedicated regression tests. Ready for review! |
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.
Fixes #149
/claim #149
Summary
Resolves four file and event consistency bugs in
file-server:routes/files/delete.ts):file_idandfile_pathnow returns HTTP400("Provide only one of file_id or file_path"), preventingctx.db.deleteFilefrom deleting two files in a single request.routes/files/upsert.ts&routes/files/rename.ts):normalizePath(file_path)andnormalizePath(new_file_path). If it resolves to empty (such as""or"/"), returns HTTP400with descriptive error ("file_path must name a file"/"new_file_path must name a file").lib/db/db-client.ts):listEventsnow comparessinceusingDate.parse()epoch numbers rather than lexicographical string comparison, so timestamps with timezone offsets (e.g.+02:00,-01:00) evaluate accurately.lib/db/db-client.ts):renameFilenow returns a newly allocated events array[...state.events, createdEvent, deletedEvent]instead of mutatingstate.eventsin-place, preserving earlier snapshots.Tests
Added 4 dedicated regression test suites:
tests/routes/selector-conflict.test.ts: verifies conflicting delete selectors return 400 and preserve both files.tests/routes/empty-file-path.test.ts: verifies empty or root file paths on upsert and rename are rejected with 400.tests/routes/event-timestamp.test.ts: verifiessincecorrectly filters events with timezone offsets.tests/rename-events.test.ts: verifiesrenameFilepreserves previous event array snapshots.All 33 tests pass locally with
bun testand typecheck passes withbunx tsc --noEmit.