stride3d/stride · error · InvalidOperationException
Unable to read asset index entry
Error message
Unable to read asset index entry [{0}]. Expecting: [path objectId] What it means
ContentIndexMap.ReadEntries parses a text index file where every non-comment line must match the pattern 'path objectId' (matched by regexEntry). A line that does not match means the index file is malformed, so ReadEntries throws InvalidOperationException naming the offending line.
Solutions
- Open the index file and fix or remove the malformed line so it reads 'path objectId'
- Restore the index file from backup or regenerate it by re-saving the assets/package
- Check for a trailing partial line from an interrupted write and delete it
Example fix
// before (index file) assets/myasset # missing objectId // after assets/myasset 0123456789abcdef0123456789abcdef
Defensive patterns
Strategy: try-catch
Validate before calling
static bool IsValidIndexLine(string line, Regex regexEntry) =>
line.Length == 0 || line.StartsWith('#') || regexEntry.IsMatch(line); Try / catch
try { contentIndexMap.Load(); }
catch (InvalidOperationException ex) when (ex.Message.StartsWith("Unable to read asset index entry"))
{
Log.Error(ex, "Corrupt index file; regenerating from source assets");
// rebuild or restore the index
} Prevention
- Never hand-edit index files; use library APIs to modify them
- Validate/backup the index before large operations
- Handle crash recovery by truncating partial trailing lines
- Keep index format consistent across Stride versions
When it happens
Trigger: A truncated or hand-edited index file; a line with missing ObjectId, extra fields, or an unescaped path containing the separator; output written by an incompatible older/newer format.
Common situations: Crash or disk-full left a partial last line; manual editing of the .idx file; merging index files from different Stride versions.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Aliases are not supported in JSON
- At least one profile must be specified.
- Attributes can not be null
- Can't deduce data serializer type for generic types.
- Can't find a type with alias
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/09951f15720161a3.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Serialization/Serialization/Contents/ContentIndexMap.cs:115
}
}
protected override List<KeyValuePair<string, ObjectId>> ReadEntries(Stream localStream)
{
ArgumentNullException.ThrowIfNull(localStream);
var reader = new StreamReader(localStream, Encoding.UTF8);
var entries = new List<KeyValuePair<string, ObjectId>>();
while (reader.ReadLine() is { } line)
{
line = line.Trim();
if (line.Length == 0 || line.StartsWith('#'))
continue;
var match = regexEntry.Match(line);
if (!match.Success)
{
throw new InvalidOperationException("Unable to read asset index entry [{0}]. Expecting: [path objectId]".ToFormat(line));
}
var url = match.Groups[1].Value;
var objectIdStr = match.Groups[2].Value;
// Test if the name has leading or ending spaces
var matchSpace = regexEntrySpace.Match(line);
if (matchSpace.Success && !matchSpace.Groups[1].Value.Equals(url))
{
throw new InvalidOperationException("Assets names cannot have empty spaces before or after the name. Please rename [{0}] and compile again.".ToFormat(matchSpace.Groups[1].Value));
}
if (!ObjectId.TryParse(objectIdStr, out var objectId))
{
throw new InvalidOperationException("Unable to decode objectid [{0}] when reading asset index".ToFormat(objectIdStr));
}
var entry = new KeyValuePair<string, ObjectId>(url, objectId);View on GitHub (pinned to 96fad776d2)