mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[GH-ISSUE #747] [Feature]: add explicit null-guard to storage.create/update in both folder route modules #355
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#355
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 @coderabbitai[bot] on GitHub (May 12, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/747
Originally assigned to: @Romuromylus on GitHub.
What problem does this solve?
The folder route modules (
packages/server/src/routes/connection-folders.routes.tsand the parallelpackages/server/src/routes/chat-folders.routes.ts) use a non-null assertion (folder!.collapsed) afterstorage.create/storage.updatein their POST and PATCH handlers.This is currently safe — both storage methods resolve via
getById(id)immediately after the insert/update, so anullreturn would only happen if the underlying SQL silently failed (which would have thrown first). The PATCH path additionally has agetByIdprecheck that guarantees the row exists.That said, the non-null assertion is a fragile coupling: if the storage layer ever evolves to handle creation failures differently (e.g. returning
nullon a constraint violation rather than throwing), every handler usingfolder!would explode at runtime with a crypticCannot read property 'collapsed' of null.Proposed solution
Replace the non-null assertion with an explicit guard in both folder route modules, in lockstep:
Both
connection-folders.routes.tsandchat-folders.routes.tsshould be updated in the same PR — diverging patterns between two analogous modules invites confusion for future contributors.Alternatives considered
storage.create/updateto throw on missing post-write fetch — semantically equivalent to the current behaviour; doesn't remove the type-levelT | nullproblem at the route boundary.The explicit
if (!folder)guard is the smallest change that satisfies the type system without altering observable behaviour for any current code path.Additional context
Raised during CodeRabbit review of PR #745 (specifically this thread). Filed as a lockstep follow-up so the connection-folders implementation in #745 stays consistent with the existing chat-folders pattern rather than diverging mid-feature.
Template check
Please uncheck (untick) the box below before submitting so we know you read the template. It is intentionally pre-checked:
@cha1latte commented on GitHub (May 12, 2026):
Triage note: labeling this as
normal-scopebecause it is a narrow route hardening change for existing folder modules.The least risky next step is to add explicit null guards in both parallel route modules without changing current successful create/update behavior.