{"record":{"id":"7ff662f6edf942a1","repo":"apache/skywalking","slug":"yaml-parse-failure-for-sourcename","errorCode":null,"errorMessage":"YAML parse failure for {sourceName}","messagePattern":"YAML parse failure for (.+?)","errorType":"http","errorClass":"ApplyException","httpStatus":500,"severity":"error","filePath":"oap-server/server-admin/runtime-rule/src/main/java/org/apache/skywalking/oap/server/receiver/runtimerule/apply/MalFileApplier.java","lineNumber":293,"sourceCode":"            final Rule rule = new Yaml().loadAs(reader, Rule.class);\n            if (rule == null) {\n                throw new ApplyException(\"YAML parsed to null — empty or malformed rule file: \"\n                    + sourceName, null, Collections.emptySet());\n            }\n            if (rule.getName() == null || rule.getName().isEmpty()) {\n                rule.setName(sourceName);\n            }\n            // Stamp YAML source anchors from the SAME text we just bound, so a hot-updated rule\n            // gets the same line provenance a disk-loaded one does.\n            RuleSourceLines.assign(rule, yamlContent);\n            // layerDefinitions: are now permitted in runtime MAL rules; they're handled by\n            // the layer registry on the apply path below. The rejection that used to live\n            // here was removed when runtime dynamic layers became a first-class feature.\n            return rule;\n        } catch (final ApplyException e) {\n            throw e;\n        } catch (final Throwable t) {\n            throw new ApplyException(\"YAML parse failure for \" + sourceName, t, Collections.emptySet());\n        }\n    }\n\n    /**\n     * Build {@link LayerClaim}s for every {@code layerDefinitions:} entry in {@code rule}.\n     * The list is ordered the same as the YAML for stable diagnostic output.\n     *\n     * <p>{@code ordinal:} is mandatory in runtime DSL — the registry-side validation rejects\n     * any entry whose ordinal is below {@link Layer#RUNTIME_DYNAMIC_MIN_ORDINAL} (including\n     * the default {@code 0} that an omitted-yaml-key produces) with applyStatus\n     * {@code layer_ordinal_out_of_range}. {@code normal:} is optional and defaults to\n     * {@code true} via {@link LayerDefinition}'s field initializer — same semantics as the\n     * bundled {@code layerDefinitions:} blocks and {@code layer-extensions.yml}.\n     *\n     * <p>An empty {@code layerDefinitions:} block returns an empty list — callers may pass\n     * it straight to {@link RuntimeLayerRegistry#apply}, which is a no-op for empty input.\n     */\n    private static List<LayerClaim> extractLayerClaims(final Rule rule) {","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/apache/skywalking/blob/102af09b4a56064e22050dded10e2c52e490d040/oap-server/server-admin/runtime-rule/src/main/java/org/apache/skywalking/oap/server/receiver/runtimerule/apply/MalFileApplier.java#L275-L311","documentation":"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).","triggerScenarios":"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.","commonSituations":"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","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"try (StringReader r = new StringReader(content)) {\n    final Rule rule = new Yaml().loadAs(r, Rule.class);\n    if (rule == null) reject(\"empty\");\n    RuleSourceLines.assign(rule, content); // exercises the same line-stamping step\n}","typeGuard":null,"tryCatchPattern":"catch (ApplyException e) when 'YAML parse failure for': surface e.getCause()'s mark; content defect — fix and re-submit, no state to unwind.","preventionTips":["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"],"tags":["yaml","mal","parse","runtime-rule"],"backgroundTag":null,"analyzedSha":"102af09b4a56064e22050dded10e2c52e490d040","analyzedAt":"2026-08-14T10:47:52.647Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}