Repository navigation
MCP: path, type, panel, library, style and ruler indices refuse a wrong-type value - #7402
Merged
bflatastic merged 4 commits intoNov 14, 2026
Merged
Conversation
…ng-type value A required index given as something other than a whole number of 0 or more, such as "3", 2.5, -1 or true, was reported as missing: `anchor` of path.setHandle, path.moveAnchor and text.setPathHandle, `segment` of path.insertAnchor, and `to` of artboard.reorder, library.moveGroup and graphicStyle.move. Each now refuses it with "`anchor` must be a whole number", naming the key; left out or null, it is still missing. An optional `subpath` of path.appendAnchor, path.close and path.reverse given that way was read as left out, so the command extended, closed or reversed the default subpath (path.reverse reversed every subpath). The `artboard` of the ruler origin commands answered "index out of range" for such a value and for null. Both now refuse such a value with the same message and change nothing. A null `artboard` is artboard 0, as one left out is; a whole number past the artboards is still out of range.
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 7 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
3 of 4 tasks
3 of 4 tasks
Member
|
Merged, thanks @dotCooCoo! It passed its CI checks. |
3 of 4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What and why
Several commands read an index with
.and_then(Value::as_u64), so a value such as"3",2.5,-1ortruewas treated as if it had been left out. A required index was reported as missing, and an optional one silently took its default. VectorCraft's own rule is that a supplied value of the wrong type is refused, and a default applies only to a value that is left out.index_opt(crates/engine/src/cmd.rs), reads an optional index: left out or null givesNone, and any other value that is not a whole number of 0 or more is refused with "{key}must be a whole number", the messageobject_paramand MCP: an integer given as a string or a fraction is refused as the wrong type, not reported as missing #7376 use. The catalogs already hold this message.anchorofpath.setHandle,path.moveAnchorandtext.setPathHandle,segmentofpath.insertAnchor, andtoofartboard.reorder,library.moveGroupandgraphicStyle.move. Left out or null, each is still reported as missing.subpathofpath.appendAnchor,path.closeandpath.reverserefuses such a value. Before, the command extended or closed the default subpath, andpath.reversereversed every subpath. The read also no longer casts withas usize.artboardofdocument.rulerOrigin,document.setRulerOriginanddocument.resetRulerOriginrefuses such a value with the whole-number message instead of "index out of range". A whole number past the artboards is still "index out of range".artboardon the ruler origin commands is now artboard 0, as a left-out one is, where it used to answer "index out of range".docs/mcp.mdanddocs/target-app-parity.mddescribe the new checks.This does not depend on #7376; the two add separate helpers in
cmd.rsandgit merge-treereports no conflict between them. The branch merges cleanly withmainat1e4e3534f5e.How it was tested
New test
tests::params::a_malformed_index_is_not_missing_or_its_default(crates/engine/src/tests/params.rs): for each command above,"3",2.5,-1,true,[]and{}are refused with the whole-number message naming the key; a required index left out or null is still missing; a whole-numberartboardpast the artboards is still out of range; the document and undo history are unchanged; and an optional index left out or null still runs with its default. It fails without the change, both withindex_optreading a malformed value as left out (path.setHandleanswers "missing anchor") and with only the oldpath.reverseread restored (it reverses the whole path).On
mainat1e4e3534f5emerged with this branch:cargo fmt --all -- --check: the only diff is incrates/svg/src/lib.rs(line 491), which this branch does not change;mainat1e4e3534f5ehas the same diff.cargo clippy -p vectorcraft-engine --all-targets -- -D warningscargo check --workspace --testscargo test -p vectorcraft-engine --lib -- tests::library tests::stylepanel tests::panelcmds tests::params tests::textedit tests::draw2 tests::menucmds::artboard: 466 passed, 0 failed.cargo test -p vectorcraft-engine --test it -- ruler_origin: 10 passed, 0 failed.cargo xtask brands,layersandassets.cargo xtask ciruns in this pull request's CI.Checklist
cargo xtask cipasses (fmt, clippy, tests, assets, brands, layers, wasm).unwrap(),expect(),panic!,unreachable!,todo!orunimplemented!outside tests, and no unchecked indexing on data from files, parameters ormessages. Errors are returned as
Resultand shown to the user(why and how).
ASSETS.md.