mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #1891] [Issue]: storage_create can overwrite an existing record when the caller supplies a duplicate id #915
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#915
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @Xelvanis on GitHub (Jun 2, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/1891
Originally assigned to: @Promansis on GitHub.
Summary
storage_createcan replace an existing row when the caller supplies anidthat already exists in the target collection.FileStorage::createremoves any row with the sameidand then pushes the new record.Expected behavior
Create semantics should reject duplicate IDs. Intentional replacement should go through an explicit update or upsert path.
Actual behavior
A duplicate caller-provided
idis treated like an implicit upsert for most collections.Steps to reproduce
storage_createorFileStorage::createto create a record withid: "duplicate-test"in a collection.idand different content.Expected: duplicate create fails.
Actual from code inspection: the old row is removed and the new row is written.
Impact area
Environment
e546fdf2/api/invokeLogs, screenshots, or video
Static evidence:
src-tauri/crates/storage/src/lib.rs:FileStorage::createassigns the incoming or generatedid, then callsrows.retain(...)to remove any existing row with thatidbefore writing the collection.onConflictDoUpdate.Regression notes
Legacy file-native insert semantics rejected duplicate primary keys unless an explicit conflict-update path was used. Refactor currently makes replacement implicit in the generic create path.
Additional context
Suggested fix: make
FileStorage::createreject an existing non-empty caller-providedid; keepupsert_with_idor update paths for intentional replacement. Add a focused Rust test proving duplicate create does not mutate the existing row.Template check