Rust codegen: MapRef::from_valdi and Map::from_valdi do not validate that the value is a map, causing len()/is_empty() to panic
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 78/100
Research direction
Start in valdi_core/src/valdi_core/rust/collections.rs and compare MapRef::from_valdi with ArrayRef::from_valdi, which the issue identifies as the validation example. Check how valdi_rust_value_ref_map_len reports non-map values and how MapRef::len handles its result. Done when deserializing a non-map into Map or MapRef returns an error instead of allowing len() or is_empty() to panic.
Written by the indexing model from the issue text.
Description
Found while reviewing https://github.com/Snapchat/Valdi/pull/211 (native Rust code generation). Not blocking that PR.
MapRef::from_valdi and Map::from_valdi do not validate that the value is a map, causing len()/is_empty() to panic
File: valdi_core/src/valdi_core/rust/collections.rs
When a non-map Value (such as a number, string, null, or typed object) is passed from JS or C++ into a Rust function expecting Map or MapRef, deserialization succeeds instead of returning an error, and a subsequent len() or is_empty() call panics. MapRef::from_valdi and Map::from_valdi accept any ValueRef without checking its runtime type, unlike ArrayRef::from_valdi.
Because MapRef::len unwraps valdi_rust_value_ref_map_len with .expect("MapRef always contains a Valdi map"), any non-map value that reaches len() or is_empty() panics instead of failing cleanly during ValdiDeserialize::from_valdi.
Validate the value in MapRef::from_valdi by calling valdi_rust_value_ref_map_len (as ArrayRef::from_valdi does with array_len) and delegate Map::from_valdi through MapRef::from_valdi(value)?.to_owned().
- Dominant language
- C++
- Stars
- 16.4k
- Forks
- 539
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Snapchat/Valdi
-
Difficulty 2/5 1-3 hours Newbie friendliness 79/100
Maintainers usually reply within 1 day
-
Rust codegen: RustMethodResolver fails to unwrap .nullable on optional interface/module methodsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
deepseek-ai/DeepGEMM-Ascend#49 ·
Maintainers usually reply within 1 day
-
bug needs testing platform:windows topic:buildsystem topic:platforms
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
godotengine/godot#126110 · 1 comment ·
Maintainers usually reply within 1 day
-
comp-s3queue
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
ClickHouse/ClickHouse#137649 ·
Maintainers usually reply within 1 day
-
area/docdb kind/enhancement mvu-pg15-pg19 priority/low
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
yugabyte/yugabyte-db#40355 ·
Maintainers usually reply within 1 day
-
Clear params.inputs in dials.indexPossibly taken @phyy-nx claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
dials/dials#3361 · 1 comment ·
Maintainers usually reply within 1 day