stride3d/stride · error · InvalidOperationException
The path [ ] contains a non-valid item id on an dictionary.
Error message
The path [{ToString()}] contains a non-valid item id on an dictionary. What it means
Thrown by YamlAssetPath.ToMemberPath when an ItemId path element resolves against a dictionary but the derived key is null. A null key cannot address any dictionary entry, so the library rejects the path rather than producing an invalid MemberPath node.
Solutions
- Update the asset YAML to reference an existing dictionary key
- Re-add the missing dictionary entry or migrate stored ids after refactoring key types
- Regenerate the reference in the editor so the id map and path stay in sync
- Catch InvalidOperationException around ToMemberPath and treat it as a stale reference to repair
Example fix
// before (yaml references an id missing from the dictionary) myDict: !AssetRef itemId="missing" // after myDict: !AssetRef key="existingKey"
Defensive patterns
Strategy: validation
Validate before calling
var key = ids.GetKey(itemId); if (key is null) throw new ArgumentException("Dictionary item id does not resolve to a key"); Type guard
bool HasValidDictKey(CollectionItemIds ids, ItemId id) => ids.GetKey(id) != null;
Try / catch
try { memberPath = yamlPath.ToMemberPath(); } catch (InvalidOperationException) { MarkReferenceBroken(asset, yamlPath); } Prevention
- Re-generate references after deleting or renaming dictionary entries
- Keep item-id maps in sync when refactoring dictionary key types
- Avoid merging asset files whose id maps have diverged
- Validate stored item ids against the live object before resolving paths
When it happens
Trigger: In the ElementType.ItemId branch, currentObject's descriptor is a DictionaryDescriptor and the key obtained from CollectionItemIdHelper.GetCollectionItemIds(currentObject).GetKey(item.AsItemId()) is null.
Common situations: Stored item id no longer present in the dictionary's id map (entry deleted or renamed); asset YAML serialized by an older/other tool version; hand-edited paths pointing at removed dictionary entries.
Understand the failure class
Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.
Related errors
- The path [ ] contains a null key on an dictionary.
- The path [ ] contains a non-valid item id on an array.
- The path [ ] contains a non-valid item id on a collection.
- Non-scalar key not yet supported!
- The path [ ] contains non-integer index on an array.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/23bc88623cd5415c.
Report an issue: GitHub.
Appendix: source
Thrown at sources/assets/Stride.Core.Assets/Yaml/YamlAssetPath.cs:321
{
if (item.Value is null && !collectionDescriptor.ElementType.IsNullable())
{
throw new InvalidOperationException($"The path [{ToString()}] contains a null item on a set.");
}
}
else
{
if (key is not int)
{
throw new InvalidOperationException($"The path [{ToString()}] contains a non-valid item id on a collection.");
}
}
memberPath.Push(collectionDescriptor, key);
currentObject = collectionDescriptor.GetValue(currentObject, key);
}
else if (typeDescriptor is DictionaryDescriptor dictionaryDescriptor)
{
if (key is null) throw new InvalidOperationException($"The path [{ToString()}] contains a non-valid item id on an dictionary.");
memberPath.Push(dictionaryDescriptor, key);
currentObject = dictionaryDescriptor.GetValue(currentObject, key);
}
break;
}
default:
throw new ArgumentOutOfRangeException();
}
}
return memberPath;
}
/// <summary>
/// Creates a <see cref="YamlAssetPath"/> out of a <see cref="MemberPath"/> instance.
/// </summary>
/// <param name="path">The <see cref="MemberPath"/> from which to create a <see cref="YamlAssetPath"/>.</param>
/// <param name="root">The root object of the given <see cref="MemberPath"/>.</param>View on GitHub (pinned to 96fad776d2)