{"record":{"id":"dfbec91fa85d8549","repo":"juanfont/headscale","slug":"tag-q-w-q","errorCode":null,"errorMessage":"tag %q %w %q","messagePattern":"tag %q %w %q","errorType":"validation","errorClass":"ErrUndefinedTagReference","httpStatus":400,"severity":"error","filePath":"hscontrol/policy/v2/policy.go","lineNumber":1674,"sourceCode":"// edge and contribute no addresses; non-cycle owners on the cycled tags\n// still resolve. Undefined-tag references remain a hard error.\nfunc flattenTags(tagOwners TagOwners, tag Tag, visiting map[Tag]bool, chain []Tag) (Owners, error) {\n\tif visiting[tag] {\n\t\treturn nil, nil\n\t}\n\n\tvisiting[tag] = true\n\n\tchain = append(chain, tag)\n\tdefer delete(visiting, tag)\n\n\tvar result Owners\n\n\tfor _, owner := range tagOwners[tag] {\n\t\tswitch o := owner.(type) {\n\t\tcase *Tag:\n\t\t\tif _, ok := tagOwners[*o]; !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"tag %q %w %q\", tag, ErrUndefinedTagReference, *o)\n\t\t\t}\n\n\t\t\tnested, err := flattenTags(tagOwners, *o, visiting, chain)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\n\t\t\tresult = append(result, nested...)\n\t\tdefault:\n\t\t\tresult = append(result, owner)\n\t\t}\n\t}\n\n\treturn result, nil\n}\n\n// flattenTagOwners flattens all [TagOwners] by resolving nested tags and detecting cycles.\n// It will return a new [TagOwners] map where all the [Tag] types have been resolved to their underlying [Owners].","sourceCodeStart":1656,"sourceCodeEnd":1692,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/hscontrol/policy/v2/policy.go#L1656-L1692","documentation":"Error \"tag %q %w %q\" thrown in juanfont/headscale.","triggerScenarios":"Thrown at hscontrol/policy/v2/policy.go:1674 when the library encounters an invalid state.","commonSituations":"A tag reference in the policy is invalid or undefined. Define the tag in tagOwners and ensure it starts with 'tag:'.","solutions":["Inspect the wrapped error for the underlying cause and correct the failing condition (tag); retry the operation after fixing the input, configuration, or environment."],"exampleFix":"Inspect the wrapped error for the underlying cause and correct the failing condition (tag); retry the operation after fixing the input, configuration, or environment.","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"565fd254d06c4c7f9a8cad1714a43445c79ba420","analyzedAt":"2026-08-15T13:12:30.133Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}