{"record":{"id":"40621accf6004aac","repo":"juanfont/headscale","slug":"w-s-40621a","errorCode":null,"errorMessage":"%w: %s","messagePattern":"%w: %s","errorType":"validation","errorClass":"ErrNodeNameNotUnique","httpStatus":400,"severity":"error","filePath":"hscontrol/state/state.go","lineNumber":1054,"sourceCode":"\n// RenameNode changes the display name of a node. The admin supplies\n// the exact DNS label they want; malformed input is rejected (no\n// auto-sanitisation) and collisions error out rather than silently\n// bumping a user-facing label. See HOSTNAME.md for the CLI contract.\nfunc (s *State) RenameNode(nodeID types.NodeID, newName string) (types.NodeView, change.Change, error) {\n\t// Validate the label AND that the resulting FQDN fits MaxHostnameLength:\n\t// a valid 63-char label can still overflow under a long base_domain, and\n\t// an unmappable name would break this node and its peers (issue #3346).\n\terr := types.ValidateGivenName(newName, s.cfg.BaseDomain)\n\tif err != nil {\n\t\treturn types.NodeView{}, change.Change{}, fmt.Errorf(\"%w: %w\", ErrGivenNameInvalid, err)\n\t}\n\n\tview, err := s.nodeStore.SetGivenName(nodeID, newName)\n\tif err != nil {\n\t\tswitch {\n\t\tcase errors.Is(err, ErrGivenNameTaken):\n\t\t\treturn types.NodeView{}, change.Change{}, fmt.Errorf(\"%w: %s\", ErrNodeNameNotUnique, newName)\n\t\tcase errors.Is(err, ErrNodeNotFound):\n\t\t\treturn types.NodeView{}, change.Change{}, fmt.Errorf(\"%w: %d\", ErrNodeNotInNodeStore, nodeID)\n\t\tdefault:\n\t\t\treturn types.NodeView{}, change.Change{}, fmt.Errorf(\"renaming node: %w\", err)\n\t\t}\n\t}\n\n\treturn s.persistNodeToDB(view)\n}\n\n// BackfillNodeIPs assigns IP addresses to nodes that don't have them.\nfunc (s *State) BackfillNodeIPs() ([]string, error) {\n\tchanges, err := s.db.BackfillNodeIPs(s.ipAlloc)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Refresh [NodeStore] after IP changes to ensure consistency","sourceCodeStart":1036,"sourceCodeEnd":1072,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/hscontrol/state/state.go#L1036-L1072","documentation":"Error \"%w: %s\" thrown in juanfont/headscale.","triggerScenarios":"Thrown at hscontrol/state/state.go:1054 when the library encounters an invalid state.","commonSituations":"A state operation on the named entity failed. Verify the entity exists and the operation's inputs are valid.","solutions":["Inspect the wrapped error for the underlying cause and correct the failing condition (); retry the operation after fixing the input, configuration, or environment."],"exampleFix":"Inspect the wrapped error for the underlying cause and correct the failing condition (); 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"}