Repository navigation
fix: enforce file selector, root path, and event snapshot consistency - #182
Open
huangji6693-max wants to merge 1 commit into
Open
huangji6693-max wants to merge 1 commit into
huangji6693-max wants to merge 1 commit into
Conversation
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.
Summary
Fixes four file and event consistency defects reported in #149:
/files/deleteselectors (routes/files/delete.ts): Reject requests supplying bothfile_idandfile_pathwith HTTP 400 (Provide only one of file_id or file_path) before mutating state so a single request cannot delete two distinct files while emitting only one event.routes/files/upsert.ts,routes/files/rename.ts): ValidatenormalizePath(body.file_path)andnormalizePath(body.new_file_path)and return HTTP 400 if empty (""or"/").listEvents({ since })(lib/db/db-client.ts): UseDate.parse(e.created_at) > Date.parse(since)rather than lexicographical string comparison so ISO timestamps with timezone offsets are ordered by instant.eventsarray snapshots inrenameFile(lib/db/db-client.ts): Construct a newevents: [...state.events, createdEvent, deletedEvent]array instead of mutatingstate.eventsin place.Closes #149
Fixes #149
/claim #149
Verification
bun test tests/rename-events.test.ts tests/routes/empty-file-path.test.ts tests/routes/event-timestamp.test.ts tests/routes/selector-conflict.test.ts(4 pass, 0 fail)bunx tsc --noEmitbun run format:checkMulti-Chain Payout Wallets
0x380C97bcbcAEf29DAc2d0ba7E180F1b4A7F38fddGBYWLISGOUWQ43VQEGXX6KRGDZ3CKAFFK3JXVLXKDO5TIFJUJ3OHJYOZAyXYaA9Nf4z5fpLKY6DmubWe6D2qveMd79w8pEDNHcDw