[PR #3615] [MERGED] Validate folder API request contracts #6016

Closed
opened 2026-10-23 04:06:16 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/3615
Author: @Xelvanis
Created: 7/14/2026
Status: ✅ Merged
Merged: 7/14/2026
Merged by: @SpicyMarinara

Base: staging ← Head: fix/folder-route-validation


📝 Commits (2)

  • 5661506 fix: validate folder API requests
  • fb3aac4 fix: address folder route review feedback

📊 Changes

9 files changed (+216 additions, -175 deletions)

View changed files

📝 packages/client/src/hooks/use-chat-folders.ts (+14 -13)
📝 packages/client/src/hooks/use-connection-folders.ts (+14 -14)
📝 packages/server/src/routes/chat-folders.routes.ts (+11 -67)
📝 packages/server/src/routes/connection-folders.routes.ts (+11 -64)
➕ packages/server/src/routes/folder-routes.shared.ts (+77 -0)
📝 packages/server/src/services/storage/chat-folders.storage.ts (+10 -9)
📝 packages/server/src/services/storage/connection-folders.storage.ts (+9 -8)
📝 packages/shared/src/index.ts (+1 -0)
➕ packages/shared/src/schemas/folder.schema.ts (+69 -0)

📄 Description

Linked issue

Closes #3614

Why this change

The chat-folder and connection-folder APIs duplicated their request contracts and only partially validated bodies at runtime. Malformed values could reach route or storage logic, including a numeric name reaching .trim() and becoming a 500, while reorder and move payloads accepted unchecked values.

What changed

  • Added shared Zod schemas and inferred request types for folder create, update, move, and reorder operations.
  • Added a narrow shared CRUD route registrar for behavior common to chat and connection folders.
  • Kept entity-specific chat/connection movement and storage behavior separate.
  • Reused the canonical request types in the client hooks and storage interfaces.
  • Rejects empty IDs, invalid update values, and duplicate reorder IDs before storage writes.

Validation

  • pnpm check passes locally
  • Container (Docker / Podman) built and ran without issue
  • Ran the app, clicked through the changes manually
  • Checked edge cases (light + dark mode, mobile viewport, empty states, error paths)
  • Above manual verification completed (describe below)
  • Read and followed CONTRIBUTING.md

pnpm check passed locally after commit, including TypeScript, ESLint, and production builds. The validation checkbox remains unchecked for human confirmation as required by the repository workflow.

Manual verification notes

  • In Google Chrome, created, renamed, collapsed, refreshed, and deleted temporary chat and connection folders; all observed API responses were 200.
  • Reordered chat folders and moved an existing chat into and back out of the temporary folder; its original folder and exact order were restored.
  • Confirmed folder names and collapsed states survived a browser refresh.
  • Confirmed no temporary folders remained and no browser console warnings/errors were recorded.
  • A temporary Fastify proof also covered create/update compatibility, duplicate reorder rejection without state changes, missing-folder deletion, and response serialization; no test files were retained.
  • Not manually verified: connection drag/reorder, populated-folder deletion, color changes (no current UI control), full process restart, Docker, mobile, or light-mode behavior.

Docs and release impact

  • No docs changes needed
  • Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed
  • Version/release files updated (only if this PR includes a version bump)

No documentation or release metadata changes are needed; this is an internal API validation/refactor change.

UI evidence (if applicable)

Not applicable: no visual UI behavior or styling changed.

Summary by CodeRabbit

  • New Features

    • Added consistent validation for creating, updating, moving, and reordering chat and connection folders.
    • Prevented invalid or duplicate folder and item ordering submissions.
    • Standardized folder management behavior across chat and connection folders.
  • Bug Fixes

    • Improved handling of invalid folder requests with clearer validation and error responses.

🔄 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/3615 **Author:** [@Xelvanis](https://github.com/Xelvanis) **Created:** 7/14/2026 **Status:** ✅ Merged **Merged:** 7/14/2026 **Merged by:** [@SpicyMarinara](https://github.com/SpicyMarinara) **Base:** `staging` ← **Head:** `fix/folder-route-validation` --- ### 📝 Commits (2) - [`5661506`](https://github.com/Pasta-Devs/Marinara-Engine/commit/56615068db3ca5798929fbc8662ef487466878c0) fix: validate folder API requests - [`fb3aac4`](https://github.com/Pasta-Devs/Marinara-Engine/commit/fb3aac426cc5b65d63dd470d0d16f5c48b4c20bc) fix: address folder route review feedback ### 📊 Changes **9 files changed** (+216 additions, -175 deletions) <details> <summary>View changed files</summary> 📝 `packages/client/src/hooks/use-chat-folders.ts` (+14 -13) 📝 `packages/client/src/hooks/use-connection-folders.ts` (+14 -14) 📝 `packages/server/src/routes/chat-folders.routes.ts` (+11 -67) 📝 `packages/server/src/routes/connection-folders.routes.ts` (+11 -64) ➕ `packages/server/src/routes/folder-routes.shared.ts` (+77 -0) 📝 `packages/server/src/services/storage/chat-folders.storage.ts` (+10 -9) 📝 `packages/server/src/services/storage/connection-folders.storage.ts` (+9 -8) 📝 `packages/shared/src/index.ts` (+1 -0) ➕ `packages/shared/src/schemas/folder.schema.ts` (+69 -0) </details> ### 📄 Description ## Linked issue Closes #3614 ## Why this change The chat-folder and connection-folder APIs duplicated their request contracts and only partially validated bodies at runtime. Malformed values could reach route or storage logic, including a numeric `name` reaching `.trim()` and becoming a `500`, while reorder and move payloads accepted unchecked values. ## What changed - Added shared Zod schemas and inferred request types for folder create, update, move, and reorder operations. - Added a narrow shared CRUD route registrar for behavior common to chat and connection folders. - Kept entity-specific chat/connection movement and storage behavior separate. - Reused the canonical request types in the client hooks and storage interfaces. - Rejects empty IDs, invalid update values, and duplicate reorder IDs before storage writes. ## Validation - [x] `pnpm check` passes locally - [ ] Container (Docker / Podman) built and ran without issue - [x] Ran the app, clicked through the changes manually - [x] Checked edge cases (light + dark mode, mobile viewport, empty states, error paths) - [x] Above manual verification completed (describe below) - [x] Read and followed `CONTRIBUTING.md` `pnpm check` passed locally after commit, including TypeScript, ESLint, and production builds. The validation checkbox remains unchecked for human confirmation as required by the repository workflow. ### Manual verification notes - In Google Chrome, created, renamed, collapsed, refreshed, and deleted temporary chat and connection folders; all observed API responses were `200`. - Reordered chat folders and moved an existing chat into and back out of the temporary folder; its original folder and exact order were restored. - Confirmed folder names and collapsed states survived a browser refresh. - Confirmed no temporary folders remained and no browser console warnings/errors were recorded. - A temporary Fastify proof also covered create/update compatibility, duplicate reorder rejection without state changes, missing-folder deletion, and response serialization; no test files were retained. - Not manually verified: connection drag/reorder, populated-folder deletion, color changes (no current UI control), full process restart, Docker, mobile, or light-mode behavior. ## Docs and release impact - [x] No docs changes needed - [ ] Updated docs (README / CONTRIBUTING / android/README / CHANGELOG) as needed - [ ] Version/release files updated (only if this PR includes a version bump) No documentation or release metadata changes are needed; this is an internal API validation/refactor change. ## UI evidence (if applicable) Not applicable: no visual UI behavior or styling changed. <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added consistent validation for creating, updating, moving, and reordering chat and connection folders. * Prevented invalid or duplicate folder and item ordering submissions. * Standardized folder management behavior across chat and connection folders. * **Bug Fixes** * Improved handling of invalid folder requests with clearer validation and error responses. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-23 04:06:16 +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#6016
No description provided.