{"record":{"id":"ce1fba60a69c0199","repo":"stride3d/stride","slug":"the-anchor-0-does-not-exists","errorCode":null,"errorMessage":"The anchor '{0}' does not exists","messagePattern":"The anchor '(.+?)' does not exists","errorType":"exception","errorClass":"AnchorNotFoundException","httpStatus":null,"severity":"error","filePath":"sources/core/Stride.Core.Yaml/Serialization/DocumentLoadingState.cs","lineNumber":96,"sourceCode":"\n        /// <summary>\n        /// Gets the node with the specified anchor.\n        /// </summary>\n        /// <param name=\"anchor\">The anchor.</param>\n        /// <param name=\"throwException\">if set to <c>true</c>, the method should throw an exception if there is no node with that anchor.</param>\n        /// <param name=\"start\">The start position.</param>\n        /// <param name=\"end\">The end position.</param>\n        /// <returns></returns>\n        public YamlNode GetNode(string anchor, bool throwException, Mark start, Mark end)\n        {\n            YamlNode target;\n            if (anchors.TryGetValue(anchor, out target))\n            {\n                return target;\n            }\n            else if (throwException)\n            {\n                throw new AnchorNotFoundException(anchor, start, end, string.Format(CultureInfo.InvariantCulture, \"The anchor '{0}' does not exists\", anchor));\n            }\n            else\n            {\n                return null;\n            }\n        }\n\n        /// <summary>\n        /// Adds the specified node to the collection of nodes with unresolved aliases.\n        /// </summary>\n        /// <param name=\"node\">\n        /// The <see cref=\"YamlNode\"/> that has unresolved aliases.\n        /// </param>\n        public void AddNodeWithUnresolvedAliases(YamlNode node)\n        {\n            nodesWithUnresolvedAliases.Add(node);\n        }\n","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/core/Stride.Core.Yaml/Serialization/DocumentLoadingState.cs#L78-L114","documentation":"DocumentLoadingState.GetNode resolves an alias like *anchor to the node previously registered under that anchor; when the anchor is not found and throwException is true it throws AnchorNotFoundException. This means the document contains an alias referencing an anchor that was never defined (or not yet defined at that point).","triggerScenarios":"YAML contains *alias but the corresponding &anchor was never declared; the alias appears before its anchor in document order; a typo in the alias name; the anchor was defined in a different document/stream than the alias.","commonSituations":"Hand-written YAML referencing anchors from an included or merged file; renaming an anchor without updating aliases; copy-pasting alias nodes into documents that lack their anchors.","solutions":["Add the missing &anchor declaration before the alias use in the document","Fix the alias name typo so it matches an existing anchor","Reorder so the anchored node precedes its alias (YAML requires forward definitions only within a document)","If optional, call the lookup path with throwException=false and handle the null return"],"exampleFix":"// before\nsettings: *shared\n// after\nshared: &shared {retries: 3}\nsettings: *shared","handlingStrategy":"validation","validationCode":"var anchors = Regex.Matches(yaml, \"&([A-Za-z0-9_-]+)\").Select(m => m.Groups[1].Value).ToHashSet();\nvar aliases = Regex.Matches(yaml, \"\\*([A-Za-z0-9_-]+)\").Select(m => m.Groups[1].Value);\nvar missing = aliases.Where(a => !anchors.Contains(a)).ToList();\nif (missing.Count > 0) throw new InvalidDataException($\"Aliases without anchors: {string.Join(\",\", missing)}\");","typeGuard":null,"tryCatchPattern":"try { return serializer.Deserialize(stream, typeof(Config)); }\ncatch (AnchorNotFoundException ex) { throw new InvalidDataException($\"Alias '{ex.Anchor}' has no matching anchor\", ex); }","preventionTips":["Define every anchor before its aliases in the same document","Grep for *alias uses and verify matching &anchors during review","Rename anchors with tooling that updates aliases too","Avoid referencing anchors from other files unless merging supports it"],"tags":["yaml","aliases","anchors","parsing"],"backgroundTag":"yaml-parse-error","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}