stride3d/stride · error · ArgumentException
Expected STREAM-START.
Error message
Expected STREAM-START.
What it means
A new Emitter must receive a StreamStart event as the very first event; it initializes line/column/indent state from it. EmitStreamStart throws ArgumentException if the first event passed to Emit is anything other than StreamStart.
Solutions
- Emit a StreamStart event first: emitter.Emit(new StreamStart());
- Build the full event sequence StreamStart -> DocumentStart -> content -> DocumentEnd -> StreamEnd.
- If using an EmittingEventQueue or serializer, ensure the serializer emits the stream envelope rather than suppressing it.
Example fix
// before emitter.Emit(new DocumentStart()); // throws // after emitter.Emit(new StreamStart()); emitter.Emit(new DocumentStart());
Defensive patterns
Strategy: validation
Validate before calling
if (!(events.FirstOrDefault() is StreamStart))
emitter.Emit(new StreamStart()); // ensure stream envelope opens
foreach (var evt in events) emitter.Emit(evt); Type guard
bool StartsWithStreamStart(IEnumerable<ParsingEvent> events) => events.FirstOrDefault() is StreamStart;
Try / catch
try { emitter.Emit(evt); }
catch (ArgumentException ex) when (ex.Message == "Expected STREAM-START.") { /* restart with a fresh emitter and emit StreamStart first */ } Prevention
- Always open with StreamStart
- Build the canonical StreamStart/DocumentStart/.../StreamEnd sequence
- Prefer high-level serializers over manual Emit loops
When it happens
Trigger: Emitting a DocumentStart, Scalar, or any other event to a fresh Emitter without first emitting StreamStart.
Common situations: Hand-rolling an emitter loop and skipping the stream start; reusing an emitter mid-way after an exception left it in a fresh state; constructing events manually and forgetting StreamStart.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Expected nothing after STREAM-END
- Expected DOCUMENT-START or STREAM-END
- An IObjectNode was expected when processing the path
- An IMemberNode was expected when processing the path
- Unable to load the given stream
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/46c345dcc944b767.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Yaml/Emitter.cs:644
break;
case EmitterState.YAML_EMIT_END_STATE:
throw new YamlException("Expected nothing after STREAM-END");
default:
Debug.Assert(false, "Invalid state.");
throw new InvalidOperationException("Invalid state");
}
}
/// <summary>
/// Expect STREAM-START.
/// </summary>
private void EmitStreamStart(ParsingEvent evt)
{
if (!(evt is StreamStart))
{
throw new ArgumentException("Expected STREAM-START.", "evt");
}
indent = -1;
line = 0;
column = 0;
isWhitespace = true;
isIndentation = true;
state = EmitterState.YAML_EMIT_FIRST_DOCUMENT_START_STATE;
}
/// <summary>
/// Expect DOCUMENT-START or STREAM-END.
/// </summary>
private void EmitDocumentStart(ParsingEvent evt, bool isFirst)
{
DocumentStart documentStart = evt as DocumentStart;
if (documentStart != null)View on GitHub (pinned to 96fad776d2)