[PR #1901] [MERGED] storage: reject duplicate create ids #5339

Closed
opened 2026-10-22 04:15:22 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1901
Author: @Promansis
Created: 6/2/2026
Status: ✅ Merged
Merged: 6/2/2026
Merged by: @Promansis

Base: refactor ← Head: fix/issue-1891-storage-create


📝 Commits (1)

  • d45347d storage: reject duplicate create ids

📊 Changes

1 file changed (+53 additions, -0 deletions)

View changed files

📝 src-tauri/crates/storage/src/lib.rs (+53 -0)

📄 Description

Linked issue

Closes #1891

Why this change

  • storage_create could silently replace an existing row when the caller supplied an id already present in the target collection.
  • Create semantics should reject duplicate caller-provided IDs; intentional replacement should stay on update or upsert paths.

What changed

  • Added a duplicate-ID guard in FileStorage::create for non-empty caller-provided IDs.
  • Added a focused Rust regression test proving duplicate create fails without mutating the original row.

Refactor impact

Primary owner:

Rust storage

Impact areas reviewed:

  • Embedded Tauri storage_create command path
  • Remote runtime /api/invoke storage_create dispatch path
  • Shared storage callers across catalog resources, chat, roleplay, and game modes

Boundary notes:

  • Fixed at the Rust storage owner where both embedded and remote storage create paths converge.
  • No React, engine, shared API, command registration, or HTTP allowlist changes were needed.
  • upsert_with_id remains the explicit replacement path.

Pressure points touched:

  • None beyond src-tauri/crates/storage/src/lib.rs.

Validation

  • Matching validation command passes locally (for example pnpm typecheck, pnpm build, pnpm check:architecture, pnpm check:docs, or full pnpm check when warranted)
  • Full pnpm check passes before PR push/handoff
  • Human/manual validation completed by contributor or reviewer

Manual verification notes

  • cargo test --manifest-path src-tauri/crates/storage/Cargo.toml create_rejects_duplicate_caller_provided_id_without_mutating_existing_row
  • cargo check --manifest-path src-tauri/Cargo.toml
  • git diff --check

Feature Discoverability

Check exactly one:

  • Updated src/features/shell/discovery/ because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool.
  • N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find.

Reason:

  • Bugfix only; no new user-discoverable feature or workflow.

Docs and release impact

  • No docs changes needed
  • Updated README.md
  • Updated CONTRIBUTING.md
  • Updated docs/developer/
  • Updated repo skills or AGENTS.md
  • Confirmed this PR does not restore old staging/package-workspace/release claims

UI evidence

  • N/A; storage behavior only.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Pasta-Devs/Marinara-Engine/pull/1901 **Author:** [@Promansis](https://github.com/Promansis) **Created:** 6/2/2026 **Status:** ✅ Merged **Merged:** 6/2/2026 **Merged by:** [@Promansis](https://github.com/Promansis) **Base:** `refactor` ← **Head:** `fix/issue-1891-storage-create` --- ### 📝 Commits (1) - [`d45347d`](https://github.com/Pasta-Devs/Marinara-Engine/commit/d45347dc8713b184ec5f739d82f13faf1258ba5e) storage: reject duplicate create ids ### 📊 Changes **1 file changed** (+53 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `src-tauri/crates/storage/src/lib.rs` (+53 -0) </details> ### 📄 Description ## Linked issue Closes #1891 ## Why this change - `storage_create` could silently replace an existing row when the caller supplied an `id` already present in the target collection. - Create semantics should reject duplicate caller-provided IDs; intentional replacement should stay on update or upsert paths. ## What changed - Added a duplicate-ID guard in `FileStorage::create` for non-empty caller-provided IDs. - Added a focused Rust regression test proving duplicate create fails without mutating the original row. ## Refactor impact Primary owner: Rust storage Impact areas reviewed: - Embedded Tauri `storage_create` command path - Remote runtime `/api/invoke` `storage_create` dispatch path - Shared storage callers across catalog resources, chat, roleplay, and game modes Boundary notes: - Fixed at the Rust storage owner where both embedded and remote storage create paths converge. - No React, engine, shared API, command registration, or HTTP allowlist changes were needed. - `upsert_with_id` remains the explicit replacement path. Pressure points touched: - None beyond `src-tauri/crates/storage/src/lib.rs`. ## Validation <!-- Check only what you personally ran or manually verified. Treat unchecked items as explicit TODOs. --> <!-- Do not submit *.test.ts or *.test.tsx files as PR proof; cite existing checks, command output, app/browser/Tauri verification, or manual notes instead. --> - [x] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [x] Full `pnpm check` passes before PR push/handoff - [ ] Human/manual validation completed by contributor or reviewer ### Manual verification notes - `cargo test --manifest-path src-tauri/crates/storage/Cargo.toml create_rejects_duplicate_caller_provided_id_without_mutating_existing_row` - `cargo check --manifest-path src-tauri/Cargo.toml` - `git diff --check` ## Feature Discoverability Check exactly one: - [ ] Updated `src/features/shell/discovery/` because this PR adds or materially changes a user-discoverable feature, workflow, setting, mode, panel, import path, agent, media capability, or advanced tool. - [x] N/A because this PR is only a bugfix, refactor, test, docs, internal wiring, visual polish, copy edit, or compatibility fix and does not add a new thing users need to find. Reason: - Bugfix only; no new user-discoverable feature or workflow. ## Docs and release impact - [x] No docs changes needed - [ ] Updated `README.md` - [ ] Updated `CONTRIBUTING.md` - [ ] Updated `docs/developer/` - [ ] Updated repo skills or `AGENTS.md` - [ ] Confirmed this PR does not restore old staging/package-workspace/release claims ## UI evidence - N/A; storage behavior only. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:15:22 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#5339
No description provided.