mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #1187] [MERGED] Guard NaN and unit-test the legacy text-normalization helpers #4966
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#4966
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?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/1187
Author: @Romuromylus
Created: 5/25/2026
Status: ✅ Merged
Merged: 5/25/2026
Merged by: @Romuromylus
Base:
refactor← Head:fix/legacy-import-followup📝 Commits (2)
2732c4aAdd NaN guard and unit tests for legacy bool/array normalizers00ced39Merge branch 'refactor' into fix/legacy-import-followup📊 Changes
1 file changed (+138 additions, -0 deletions)
View changed files
📝
src-tauri/src/commands/storage/shared.rs(+138 -0)📄 Description
Why this change
Follow-up to #1181, which introduced
normalize_legacy_text_array_fieldsandnormalize_legacy_text_bool_fieldsas the final barrier between malformed legacy TEXT cells and the editor. CodeRabbit flagged in review that the bool helper treatsf64::NANas truthy (NaN != 0.0) and that neither helper has a direct unit-test matrix - both are unreachable / quick-win nits, addressed together here so the contract is locked in before the next legacy field is added.What changed
src-tauri/src/commands/storage/shared.rs: explicitis_nan()short-circuit innormalize_legacy_text_bool_fields's number branch sof64::NANreturnsfalseinstead oftrue. Defensive only -serde_json::Number::from_f64already refuses to constructValue::Number(NaN), so this is unreachable from any deserialized JSON input. The guard makes the function correct against directValueconstruction so the next refactor doesn't have to think about it.src-tauri/src/commands/storage/shared.rs: 18 new unit tests covering the normalization contract for both helpers. Array helper: already-array preserved, parseable JSON-string array parsed, unparseable string ->[], non-array JSON-string ->[], scalar / null / missing-key / non-object-record edge cases. Bool helper: already-bool preserved,"true"/"false"coerced, the truthy/falsy text aliases (1/0/yes/no/on/off, case-insensitive) coerced, unknown string defaults tofalse, integer and float zero / non-zero coerced, null defaults tofalse, missing-key / non-object-record edge cases. Matches the existing#[cfg(test)] mod testsstyle already in the file.The NaN test itself is deliberately omitted -
serde_json::Value::from(f64::NAN)returnsValue::Nullrather than a NaN number, so there's no public API path to exercise the branch. The guard remains as defensive coding for the same reason CodeRabbit flagged it.Verification
cargo test --manifest-path src-tauri/Cargo.toml- all 50 existing + 18 new tests pass, including the fullnormalize_legacy_text_*matrix.cargo clippy --manifest-path src-tauri/Cargo.toml --workspace --all-targets -- -D warnings- clean.pnpm check(architecture + frontend + docs) - clean.Manually re-imported the pre-refactor profile snapshot from #1181's test data on
pnpm tauri devto confirm the import path still works end-to-end (no behavior change from the helper edits; the test matrix locks down the existing contract).Out of scope: a separately-investigated post-import bug where imported chats fire agents (confirmed via runtime logs -
resolveAgentsresolves andrunPostexecutes the expected 4 trackers for a roleplay imported chat) but the tracker panel and agent activity panel stay empty. Will file as a separate issue with the captured evidence so it can be diagnosed properly without entangling this PR.Linked
Follow-up to #1181.
Summary by CodeRabbit
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.