stride3d/stride · error · SyntaxErrorException
Mapping keys are not allowed in this context.
Error message
Mapping keys are not allowed in this context.
What it means
YAML scanner error in FetchKey: a KEY token ('?...' or an implicit mapping key) appears in block context where simple keys are not currently allowed — typically a mapping key appearing after a value on the same line or inside a sequence item, i.e. a key placed where the grammar forbids it.
Solutions
- Move the key to its own line at the correct indentation level
- Fix block/sequence structure so keys only appear inside mappings
- Replace '? ' explicit-key syntax misuse with plain mapping syntax
Example fix
// before a: 1 ? b: 2 // after ? [a, b] : value
Defensive patterns
Strategy: validation
Try / catch
catch (SyntaxErrorException ex) { throw new ConfigFormatException($"'?' key indicator misplaced near {ex.Start.Line}:{ex.Start.Column}"); } Prevention
- Avoid explicit '? key' syntax; use simple 'key:' mappings
- Quote '?' inside scalars if it is literal content
- Place complex-key constructs alone on their lines
When it happens
Trigger: A '? key' construct appearing after a scalar on the same line or inside a context where the scanner has already consumed a node, e.g. 'a: 1 ? b'.
Common situations: Using explicit complex-key syntax ('? {a: 1}\n: value') in the wrong position, or stray '?' characters left from editing nested mappings.
Related errors
- While scanning a simple key, could not find expected ':'.
- While scanning for the next token, find character that…
- While scanning a directive, find uknown directive name.
- While scanning a directive, did not find expected comment…
- Block sequence entries are not allowed in this context.
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/3df8ee8534f56708.
Report an issue: GitHub.
Appendix: source
Thrown at sources/core/Stride.Core.Yaml/Scanner.cs:986
// Create the BLOCK-ENTRY token and append it to the queue.
tokens.Enqueue(new BlockEntry(start, mark));
}
/// <summary>
/// Produce the KEY token.
/// </summary>
private void FetchKey()
{
// In the block context, additional checks are required.
if (flowLevel == 0)
{
// Check if we are allowed to start a new key (not nessesary simple).
if (!simpleKeyAllowed)
{
throw new SyntaxErrorException(mark, mark, "Mapping keys are not allowed in this context.");
}
// Add the BLOCK-MAPPING-START token if needed.
RollIndent(mark.Column, -1, false, mark);
}
// Reset any potential simple keys on the current flow level.
RemoveSimpleKey();
// Simple keys are allowed after '?' in the block context.
simpleKeyAllowed = flowLevel == 0;
// Consume the token.
Mark start = mark;View on GitHub (pinned to 96fad776d2)