{"record":{"id":"745a9a0d6547679b","repo":"juanfont/headscale","slug":"w-w-745a9a","errorCode":null,"errorMessage":"%w: %w","messagePattern":"%w: %w","errorType":"validation","errorClass":"ErrGivenNameInvalid","httpStatus":400,"severity":"error","filePath":"hscontrol/state/state.go","lineNumber":1047,"sourceCode":"\trouteChange := !maps.Equal(prevRoutes, s.nodeStore.PrimaryRoutes())\n\tif routeChange || !c.IsFull() {\n\t\tc = change.PolicyChange()\n\t}\n\n\treturn nodeView, c, nil\n}\n\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.","sourceCodeStart":1029,"sourceCodeEnd":1065,"githubUrl":"https://github.com/juanfont/headscale/blob/565fd254d06c4c7f9a8cad1714a43445c79ba420/hscontrol/state/state.go#L1029-L1065","documentation":"Error \"%w: %w\" thrown in juanfont/headscale.","triggerScenarios":"Thrown at hscontrol/state/state.go:1047 when the library encounters an invalid state.","commonSituations":"A wrapped state operation error. The inner messages identify the failing stage; check database and policy manager health.","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"}