apache/skywalking · error · ApplyException

YAML parsed to null — empty or malformed rule file: {sourceN

Error message

YAML parsed to null — empty or malformed rule file: {sourceName}

What it means

ApplyException thrown by MalFileApplier.parse when new Yaml().loadAs(reader, Rule.class) returns null — snakeyaml yields null only for an empty document (or a document containing only a null node, e.g. just comments/whitespace). Partial set is empty because nothing was applied. This is distinct from a parse throw (error 133) and from a well-formed-but-incomplete rule (which parses fine and fails later).

Source

Thrown at oap-server/server-admin/runtime-rule/src/main/java/org/apache/skywalking/oap/server/receiver/runtimerule/apply/MalFileApplier.java:277

                }
                failures.put(name, t);
            }
        }
        if (failures != null) {
            throw new RemoveException(failures);
        }
    }

    /** Back-compat overload: full-install policy (server-side drop fires). */
    public void remove(final Set<String> metricNames) {
        remove(metricNames, StorageManipulationOpt.withSchemaChange());
    }

    private Rule parse(final String yamlContent, final String sourceName) throws ApplyException {
        try (StringReader reader = new StringReader(yamlContent)) {
            final Rule rule = new Yaml().loadAs(reader, Rule.class);
            if (rule == null) {
                throw new ApplyException("YAML parsed to null — empty or malformed rule file: "
                    + sourceName, null, Collections.emptySet());
            }
            if (rule.getName() == null || rule.getName().isEmpty()) {
                rule.setName(sourceName);
            }
            // Stamp YAML source anchors from the SAME text we just bound, so a hot-updated rule
            // gets the same line provenance a disk-loaded one does.
            RuleSourceLines.assign(rule, yamlContent);
            // layerDefinitions: are now permitted in runtime MAL rules; they're handled by
            // the layer registry on the apply path below. The rejection that used to live
            // here was removed when runtime dynamic layers became a first-class feature.
            return rule;
        } catch (final ApplyException e) {
            throw e;
        } catch (final Throwable t) {
            throw new ApplyException("YAML parse failure for " + sourceName, t, Collections.emptySet());
        }
    }

View on GitHub (pinned to 102af09b4a)

Solutions

  1. Populate the file with a valid MAL document (top-level name/metricPrefix/metricsRules) and re-apply
  2. Guard uploads: reject empty content client-side before it reaches the runtime-rule API
  3. If a pipeline produced the empty file, fix the artifact step and re-upload
  4. Delete the empty rule entry if it was meant to be a removal — use the uninstall path, not an empty apply

Example fix

# before (empty file)
# after
name: my-bundle
metricPrefix: sat
metricsRules:
  - name: throughput
    exp: "sum(sat_traffic.total)"
Defensive patterns

Strategy: validation

Validate before calling

if (content == null || content.trim().isEmpty()) reject("empty rule file");
final Object probe = new Yaml().load(content); // null for an empty/null document
if (probe == null) reject("document parses to null — no MAL content");

Try / catch

catch (ApplyException e) when 'YAML parsed to null': client-side input error — reject the upload, never retry unchanged.

Prevention

When it happens

Trigger: Applying an empty or comments-only MAL file, or content reduced to null by templating/CDN pipeline (empty variable substitution producing an empty body). loadAs returns null, the null-check fires, and the apply aborts before name-defaulting or line stamping.

Common situations: Uploading a placeholder file created by 'touch rule.yaml' before content was written; CI artifact step emitting an empty file on build failure; Copy operation interrupted, leaving a 0-byte rule file in the store

Understand the failure class

Related errors


AI-assisted analysis of apache/skywalking@102af09b4a (2026-08-14). Data as JSON: /api/errors/c011f7914713cce2. Report an issue: GitHub.