fix(rpc): harden API against destructive ops, standardize param names, validate inputs #36
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "development_rpc_api_hardening"
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?
Closes #35.
Summary
Hardens the JSON-RPC API surface against destructive operations on arbitrary paths, standardizes parameter naming across deck/slide methods, and replaces silent input mangling with explicit validation.
Changes
Safety
deck_createrequires existing parent and refuses pre-existing target (no more silent multi-level mkdir).deck_deleterequires.slidesmarker file before removal.deck_duplicaterefuses pre-existing target.Validation
handle_deck_create/rename/duplicateuse a strictvalidate_deck_namehelper (ASCII alphanumeric +_-; rejects spaces/punctuation/leading.or-). No more silent name mangling.handle_slide_insertparsesatwithas_i64+ range check; requiresat >= 1. Negative values return a real range error instead of "Missing 'at' parameter".handle_slide_save_contentrejects empty content.Parameter standardization (with deprecation alias)
deck.*RPC methods acceptdeck_path(preferred) and the legacypath(deprecated, logs a warning).deck.scanacceptsroot_path(preferred, semantically correct) andpath(legacy).openrpc.jsonadvertises only the new names; the regenerated client uses them. Downstream callercrates/hero_slides/src/main.rsupdated.dashboard.jsmigrated to new names (15 call sites).Tests
crates/hero_slides_lib/tests/deck_safety_test.rscovering create/delete/duplicate preconditions.crates/hero_slides_server/src/rpc.rscoveringvalidate_deck_nameandparam_stringhelpers.test_scan_decks) updated to create the parent dir beforedeck_create(the test relied on the old auto-mkdir behavior).cargo build --workspace: clean.cargo test -p hero_slides_lib -p hero_slides_server: 84/84 passing.Smoke test (post-deploy)
Service restarted on this branch:
Test plan
hero_proc logs hero_slides_serverwhen a stale client usespath.deck.createwith a name containing spaces or/is rejected (not silently rewritten).Follow-ups (not in this PR)
deck.readBackgroundalso takespathand was not in scope; should be normalized todeck_path.bg.*methods usepathfor a deck path; out of scope.pathanddeck_pathfor transition. Removing the legacypathfield is a separate breaking change for a future release.path/legacy aliases on RPC inputs.64213e7965fd2c6c286f