stride3d/stride · error · YamlException

Neither tag nor isImplicit flags are specified.

Error message

Neither tag nor isImplicit flags are specified.

What it means

When emitting a scalar, the emitter requires either a resolvable tag or at least one implicit flag. If the scalar has no tag (handle and suffix null) and both IsPlainImplicit and IsQuotedImplicit are false, the emitter could not know how to represent it, so it throws this YamlException.

Solutions

  1. Set IsPlainImplicit=true for plain scalars so they can be emitted without a tag
  2. Set IsQuotedImplicit=true for quoted scalars
  3. Provide an explicit tag (e.g. tag:yaml.org,2002:str) on the scalar
  4. Use existing serialization APIs (Serializer/Emitter helpers) instead of hand-building Scalar events

Example fix

// before
new Scalar(null, null, value, ScalarStyle.Plain, false, false, start, end);
// after
new Scalar(null, null, value, ScalarStyle.Plain, true, false, start, end);
Defensive patterns

Strategy: validation

Validate before calling

bool ok = !(tag == null && !isPlainImplicit && !isQuotedImplicit);
if (!ok) throw new InvalidOperationException("Scalar needs a tag or an implicit flag");

Try / catch

try { emitter.Emit(scalarEvent); }
catch (YamlException ex) when (ex.Message.Contains("Neither tag nor isImplicit")) { /* set isPlainImplicit=true and re-emit */ }

Prevention

When it happens

Trigger: Constructing a Scalar event with no Tag and with both implicit flags false (e.g. new Scalar(anchor, tag:null, value, style, isPlainImplicit:false, isQuotedImplicit:false, ...)) and emitting it.

Common situations: Building events manually in custom serialization code; converters that strip tags but forget to set implicit flags; transformations that copy nodes but rebuild Scalar events with default(false) flags.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/d6da9d1faae50b7e. Report an issue: GitHub.

Appendix: source

Thrown at sources/core/Stride.Core.Yaml/Emitter.cs:1451

            else if (!isIndentless || !forceIndentLess)
            {
                indent += bestIndent;
            }
        }

        /// <summary>
        /// Determine an acceptable scalar style.
        /// </summary>
        private void SelectScalarStyle(ParsingEvent evt)
        {
            Scalar scalar = (Scalar) evt;

            ScalarStyle style = scalar.Style;
            bool noTag = tagData.handle == null && tagData.suffix == null;

            if (noTag && !scalar.IsPlainImplicit && !scalar.IsQuotedImplicit)
            {
                throw new YamlException("Neither tag nor isImplicit flags are specified.");
            }

            if (style == ScalarStyle.Any)
            {
                style = scalarData.isMultiline ? ScalarStyle.Literal : ScalarStyle.Plain;
            }

            if (isCanonical)
            {
                style = ScalarStyle.DoubleQuoted;
            }

            // Note: if length is 1, it might be a single char and going literal might transform \n into \r\n (which is no good)
            if ((isSimpleKeyContext || scalar.Value.Length <= 1) && scalarData.isMultiline)
            {
                style = ScalarStyle.DoubleQuoted;
            }

View on GitHub (pinned to 96fad776d2)