{"record":{"id":"c5f9ce0d1ea09b64","repo":"kubernetes/kops","slug":"building-node-patch-w","errorCode":null,"errorMessage":"building node patch: %w","messagePattern":"building node patch: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"channels/pkg/nodelabeler/labeler.go","lineNumber":70,"sourceCode":"\tlabels := nodelabels.BuildMandatoryControlPlaneLabels(nodeLabels)\n\n\tshouldPatch := false\n\tfor k, v := range labels {\n\t\tif actual, found := node.Labels[k]; !found || actual != v {\n\t\t\tshouldPatch = true\n\t\t\tbreak\n\t\t}\n\t}\n\tif !shouldPatch {\n\t\treturn nil\n\t}\n\n\tklog.V(2).Infof(\"patching node %q to add labels %v\", nodeName, labels)\n\tpatch, err := json.Marshal(&nodePatch{\n\t\tMetadata: &nodePatchMetadata{Labels: labels},\n\t})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"building node patch: %w\", err)\n\t}\n\n\tklog.V(2).Infof(\"sending patch for node %q: %s\", node.Name, patch)\n\tif _, err := client.CoreV1().Nodes().Patch(ctx, node.Name, types.StrategicMergePatchType, patch, metav1.PatchOptions{FieldManager: \"kops-channels\"}); err != nil {\n\t\treturn fmt.Errorf(\"patching node %q: %w\", node.Name, err)\n\t}\n\treturn nil\n}\n","sourceCodeStart":52,"sourceCodeEnd":79,"githubUrl":"https://github.com/kubernetes/kops/blob/4c8573c808a73d578c5eadc86d410646ea0b0d73/channels/pkg/nodelabeler/labeler.go#L52-L79","documentation":"BootstrapControlPlaneNodeLabels marshals a strategic-merge patch containing the mandatory control-plane labels; this wraps json.Marshal failing. Since the payload is simple string maps, a marshal failure is unexpected and indicates a programming error in label construction.","triggerScenarios":"Thrown at channels/pkg/nodelabeler/labeler.go:70 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped marshal error and the labels built by BuildMandatoryControlPlaneLabels","Report as a kops bug if label values contain data JSON cannot encode"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"4c8573c808a73d578c5eadc86d410646ea0b0d73","analyzedAt":"2026-09-05T04:13:19.212Z","contentChangedAt":"2026-09-05T04:13:19.212Z","schemaVersion":2},"datasetVersion":"2026-09-12T07:17:12.445Z"}