Diagnose a missing Sui dynamic field with a numeric key

A client can display a key as “7” while the contract looks up a different field with the same printed number. Parent ID, key type and encoded key value all matter.

Reproduce the mismatch with one parent

Use a fresh registry in a Move test. The first assertion checks the stored key and value types, while the second probes a wider integer key. Executing add twice on the same parent and typed key aborts because an entry already exists.

use sui::dynamic_field as df;
df::add(&mut registry.id, 7u8, 300u64);
assert!(df::exists_with_type<u8, u64>(&registry.id, 7u8), 0);
assert!(!df::exists_with_type<u64, u64>(&registry.id, 7u64), 1);

Distinguish a missing name from an unexpected value

Use exists with the original typed key to test name presence, then exists_with_type to check the value schema before borrowing. If presence is true but the typed test fails, compare the deployed schema with the client decoder. Changing only the numeric formatting cannot repair the type mismatch.

Sources