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
- Populate the file with a valid MAL document (top-level name/metricPrefix/metricsRules) and re-apply
- Guard uploads: reject empty content client-side before it reaches the runtime-rule API
- If a pipeline produced the empty file, fix the artifact step and re-upload
- 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
- Reject zero-byte and comments-only files at upload time
- Fail CI builds that produce empty rule artifacts
- Use the uninstall API for removals instead of empty re-applies
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
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- Load rule {} failed
- compile_failed
- LAL YAML parsed to empty/malformed — no rules list in {sourc
- YAML parse failure for {sourceName}
- compile_failed
AI-assisted analysis of apache/skywalking@102af09b4a (2026-08-14).
Data as JSON: /api/errors/c011f7914713cce2.
Report an issue: GitHub.