apache/skywalking · error · ApplyException
YAML parse failure for {sourceName}
Error message
YAML parse failure for {sourceName} What it means
ApplyException wrapping any non-ApplyException Throwable thrown while MalFileApplier.parse deserializes MAL YAML, defaults the rule name to sourceName, or stamps source lines via RuleSourceLines.assign. The empty/parse-null ApplyException is rethrown untouched; snakeyaml syntax errors and line-stamping failures are wrapped with the source name and an empty rollback set (nothing registered yet).
Source
Thrown at oap-server/server-admin/runtime-rule/src/main/java/org/apache/skywalking/oap/server/receiver/runtimerule/apply/MalFileApplier.java:293
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());
}
}
/**
* Build {@link LayerClaim}s for every {@code layerDefinitions:} entry in {@code rule}.
* The list is ordered the same as the YAML for stable diagnostic output.
*
* <p>{@code ordinal:} is mandatory in runtime DSL — the registry-side validation rejects
* any entry whose ordinal is below {@link Layer#RUNTIME_DYNAMIC_MIN_ORDINAL} (including
* the default {@code 0} that an omitted-yaml-key produces) with applyStatus
* {@code layer_ordinal_out_of_range}. {@code normal:} is optional and defaults to
* {@code true} via {@link LayerDefinition}'s field initializer — same semantics as the
* bundled {@code layerDefinitions:} blocks and {@code layer-extensions.yml}.
*
* <p>An empty {@code layerDefinitions:} block returns an empty list — callers may pass
* it straight to {@link RuntimeLayerRegistry#apply}, which is a no-op for empty input.
*/
private static List<LayerClaim> extractLayerClaims(final Rule rule) {View on GitHub (pinned to 102af09b4a)
Solutions
- Fix the syntax error at the line/column named by the wrapped cause
- Quote all exp values and keep metricsRules as a block-style list of maps
- Lint with Yaml().loadAs(new StringReader(content), Rule.class) locally before submit
- After correcting, re-apply; no rollback is needed since the failure precedes registration
Defensive patterns
Strategy: validation
Validate before calling
try (StringReader r = new StringReader(content)) {
final Rule rule = new Yaml().loadAs(r, Rule.class);
if (rule == null) reject("empty");
RuleSourceLines.assign(rule, content); // exercises the same line-stamping step
} Try / catch
catch (ApplyException e) when 'YAML parse failure for': surface e.getCause()'s mark; content defect — fix and re-submit, no state to unwind.
Prevention
- Quote exp strings; use block-style lists for metricsRules
- Normalize line endings to LF in your toolchain
- Run the parse+line-stamp probe in CI on every rendered rule file
When it happens
Trigger: Applying MAL content with a YAML syntax error (tabs, bad indentation, unterminated string) or a structure Rule cannot be mapped onto — e.g. metricsRules as a map instead of a list. Also fires if RuleSourceLines cannot assign line anchors to a flow-style or anchor-using document.
Common situations: Unquoted expressions containing ': ' or leading special YAML characters; Windows line endings breaking block parsing; Renamed schema keys after upgrades (metricPrefix vs prefix) making mapping fail
Related errors
- LAL YAML parse failure for {sourceName}
- Load rule {} failed
- compile_failed
- LAL YAML parsed to empty/malformed — no rules list in {sourc
- MAL register failed for {sourceName} (partial)
AI-assisted analysis of apache/skywalking@102af09b4a (2026-08-14).
Data as JSON: /api/errors/7ff662f6edf942a1.
Report an issue: GitHub.