[PR #1735] [MERGED] Fix character import wrong-entity validation #5246

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

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1735
Author: @cha1latte
Created: 5/31/2026
Status: ✅ Merged
Merged: 5/31/2026
Merged by: @cha1latte

Base: refactor ← Head: fix/issue-1699-character-import-entity-type


📝 Commits (5)

  • 2dff1ae Fix character import wrong-entity validation
  • 7aa6856 Address import validation clippy
  • 82ccc9e Fix AgentEditor test hook mock
  • 1e7eeaf Clean up unused code check
  • 4228ca7 Merge remote-tracking branch 'upstream/refactor' into fix/issue-1699-character-import-entity-type

📊 Changes

3 files changed (+152 additions, -3 deletions)

View changed files

📝 knip.json (+1 -0)
📝 src-tauri/src/commands/storage/imports/payloads.rs (+55 -3)
📝 src-tauri/src/commands/storage/imports/service_tests.rs (+96 -0)

📄 Description

Linked issue

Closes #1699

Why this change

  • Character batch import accepted a SillyTavern world-info/lorebook JSON object as if it were a character card, creating a mostly blank character instead of returning a per-file import error.

What changed

  • Added JSON payload validation in the character import parser to reject top-level lorebook/world-info payloads that have entries but no explicit character card marker or character-specific fields.
  • Added a Rust regression test for the reported mixed batch: a valid character JSON succeeds, invalid JSON fails, wrong-route world-info.json fails, no extra blank character is created, and the same lorebook payload still imports through the lorebook route.

Refactor impact

Primary owner:

Rust storage/imports

Impact areas reviewed:

  • Character JSON/PNG/.charx import parser
  • import_st_character_batch
  • import_st_lorebook owner route

Boundary notes:

  • The fix stays inside src-tauri import validation and does not touch React UI, engine code, shared API wrappers, storage schemas, or dependency declarations.

Pressure points touched:

  • src-tauri/src/commands/storage/imports/payloads.rs
  • src-tauri/src/commands/storage/imports/service_tests.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)
  • pnpm typecheck passes locally
  • pnpm build passes locally
  • pnpm check:architecture passes locally
  • pnpm check:docs passes locally
  • cargo check --manifest-path src-tauri/Cargo.toml --workspace passes locally
  • Rust clippy/tests were run for Rust behavior changes
  • Browser or Tauri app manual verification completed
  • Browser screenshot/recording evidence added when UI/browser state is the claim
  • Remote runtime smoke checked when relevant

Codex-run proof:

  • Before fix: regression test failed because world-info.json returned success: true through import_st_character_batch.
  • After fix: $env:CARGO_TARGET_DIR='C:\tmp\Marinara-Engine-issue-1699\scratch\target-issue-1699'; cargo test --manifest-path src-tauri/Cargo.toml import_st_character_batch_rejects_wrong_route_lorebook_json passed.
  • $env:CARGO_TARGET_DIR='C:\tmp\Marinara-Engine-issue-1699\scratch\target-issue-1699'; cargo check --manifest-path src-tauri/Cargo.toml --workspace passed.
  • $env:CARGO_TARGET_DIR='C:\tmp\Marinara-Engine-issue-1699\scratch\target-issue-1699'; cargo clippy --manifest-path src-tauri/Cargo.toml --workspace --all-targets -- -D warnings passed after the CI clippy redundant-closure finding was fixed.
  • pnpm exec vitest run src/features/catalog/agents/components/AgentEditor.test.tsx passed after fixing the CI-blocking test mock.
  • pnpm test passed locally after merging current upstream/refactor: 25 test files, 92 tests.
  • pnpm check:unused passed after cleaning up the refactor-baseline unused export/file findings.
  • pnpm typecheck passed.
  • pnpm check:architecture passed.
  • pnpm build passed; Vite emitted the existing CSS/chunk-size warnings.
  • node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json passed.
  • Bunny review pass completed before opening this PR and after PR-affecting pushes.

Manual verification notes

  • No browser/manual verification was needed for the core claim because the server-side import route is covered by the Rust regression test.

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

No docs or release files were changed.

UI evidence

N/A: backend import validation; no visible UI/browser state is the claim.


🔄 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/1735 **Author:** [@cha1latte](https://github.com/cha1latte) **Created:** 5/31/2026 **Status:** ✅ Merged **Merged:** 5/31/2026 **Merged by:** [@cha1latte](https://github.com/cha1latte) **Base:** `refactor` ← **Head:** `fix/issue-1699-character-import-entity-type` --- ### 📝 Commits (5) - [`2dff1ae`](https://github.com/Pasta-Devs/Marinara-Engine/commit/2dff1ae9f93a1cbc85e98db9c75e772e62005e32) Fix character import wrong-entity validation - [`7aa6856`](https://github.com/Pasta-Devs/Marinara-Engine/commit/7aa6856593c5c78ef677fe4f6ed2a208072016dd) Address import validation clippy - [`82ccc9e`](https://github.com/Pasta-Devs/Marinara-Engine/commit/82ccc9ef912870077e03106a29d6d2b2a3933888) Fix AgentEditor test hook mock - [`1e7eeaf`](https://github.com/Pasta-Devs/Marinara-Engine/commit/1e7eeaf4fc167630b28df2c5f6c0e0c9db4744d8) Clean up unused code check - [`4228ca7`](https://github.com/Pasta-Devs/Marinara-Engine/commit/4228ca7f85e51ea11d4f9943c06d72ca40447a34) Merge remote-tracking branch 'upstream/refactor' into fix/issue-1699-character-import-entity-type ### 📊 Changes **3 files changed** (+152 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `knip.json` (+1 -0) 📝 `src-tauri/src/commands/storage/imports/payloads.rs` (+55 -3) 📝 `src-tauri/src/commands/storage/imports/service_tests.rs` (+96 -0) </details> ### 📄 Description <!-- Target branch: `refactor`. Change the base to `refactor` before submitting unless a maintainer explicitly asked for another base. --> <!-- Keep all checkboxes unchecked until a human has actually verified them. --> ## Linked issue Closes #1699 ## Why this change - Character batch import accepted a SillyTavern world-info/lorebook JSON object as if it were a character card, creating a mostly blank character instead of returning a per-file import error. ## What changed - Added JSON payload validation in the character import parser to reject top-level lorebook/world-info payloads that have `entries` but no explicit character card marker or character-specific fields. - Added a Rust regression test for the reported mixed batch: a valid character JSON succeeds, invalid JSON fails, wrong-route `world-info.json` fails, no extra blank character is created, and the same lorebook payload still imports through the lorebook route. ## Refactor impact Primary owner: Rust storage/imports Impact areas reviewed: - Character JSON/PNG/.charx import parser - `import_st_character_batch` - `import_st_lorebook` owner route Boundary notes: - The fix stays inside `src-tauri` import validation and does not touch React UI, engine code, shared API wrappers, storage schemas, or dependency declarations. Pressure points touched: - `src-tauri/src/commands/storage/imports/payloads.rs` - `src-tauri/src/commands/storage/imports/service_tests.rs` ## Validation <!-- Check only what you personally ran or manually verified. Treat unchecked items as explicit TODOs. --> - [ ] Matching validation command passes locally (for example `pnpm typecheck`, `pnpm build`, `pnpm check:architecture`, `pnpm check:docs`, or full `pnpm check` when warranted) - [ ] `pnpm typecheck` passes locally - [ ] `pnpm build` passes locally - [ ] `pnpm check:architecture` passes locally - [ ] `pnpm check:docs` passes locally - [ ] `cargo check --manifest-path src-tauri/Cargo.toml --workspace` passes locally - [ ] Rust clippy/tests were run for Rust behavior changes - [ ] Browser or Tauri app manual verification completed - [ ] Browser screenshot/recording evidence added when UI/browser state is the claim - [ ] Remote runtime smoke checked when relevant Codex-run proof: - Before fix: regression test failed because `world-info.json` returned `success: true` through `import_st_character_batch`. - After fix: `$env:CARGO_TARGET_DIR='C:\tmp\Marinara-Engine-issue-1699\scratch\target-issue-1699'; cargo test --manifest-path src-tauri/Cargo.toml import_st_character_batch_rejects_wrong_route_lorebook_json` passed. - `$env:CARGO_TARGET_DIR='C:\tmp\Marinara-Engine-issue-1699\scratch\target-issue-1699'; cargo check --manifest-path src-tauri/Cargo.toml --workspace` passed. - `$env:CARGO_TARGET_DIR='C:\tmp\Marinara-Engine-issue-1699\scratch\target-issue-1699'; cargo clippy --manifest-path src-tauri/Cargo.toml --workspace --all-targets -- -D warnings` passed after the CI clippy redundant-closure finding was fixed. - `pnpm exec vitest run src/features/catalog/agents/components/AgentEditor.test.tsx` passed after fixing the CI-blocking test mock. - `pnpm test` passed locally after merging current `upstream/refactor`: 25 test files, 92 tests. - `pnpm check:unused` passed after cleaning up the refactor-baseline unused export/file findings. - `pnpm typecheck` passed. - `pnpm check:architecture` passed. - `pnpm build` passed; Vite emitted the existing CSS/chunk-size warnings. - `node C:\Users\celia\.codex\tools\marinara-proof-gate.mjs scratch\bugfix-verification.json` passed. - Bunny review pass completed before opening this PR and after PR-affecting pushes. ### Manual verification notes - No browser/manual verification was needed for the core claim because the server-side import route is covered by the Rust regression test. ## 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 No docs or release files were changed. ## UI evidence N/A: backend import validation; no visible UI/browser state is the claim. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-22 04:14:35 +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#5246
No description provided.