{"record":{"id":"f50f6b9de40ff192","repo":"GoogleContainerTools/skaffold","slug":"resolving-namespace-w","errorCode":null,"errorMessage":"resolving namespace: %w","messagePattern":"resolving namespace: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/skaffold/deploy/label/labels.go","lineNumber":116,"sourceCode":"\tmodifiedJSON, _ := json.Marshal(modifiedObj)\n\tp, _ := patch.CreateTwoWayMergePatch(originalJSON, modifiedJSON, modifiedObj)\n\n\tnamespaced, gvr, err := util.GroupVersionResource(disco, modifiedObj.GetObjectKind().GroupVersionKind())\n\tif err != nil {\n\t\treturn fmt.Errorf(\"getting group version resource from obj: %w\", err)\n\t}\n\n\tif namespaced {\n\t\tvar namespace string\n\t\tif accessor.GetNamespace() != \"\" {\n\t\t\tnamespace = accessor.GetNamespace()\n\t\t} else {\n\t\t\tnamespace = res.Namespace\n\t\t}\n\n\t\tns, err := resolveNamespace(namespace, kubeContext)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"resolving namespace: %w\", err)\n\t\t}\n\n\t\tlog.Entry(ctx).Debug(\"Patching\", name, \"in namespace\", ns)\n\t\tif _, err := client.Resource(gvr).Namespace(ns).Patch(ctx, name, types.StrategicMergePatchType, p, metav1.PatchOptions{}); err != nil {\n\t\t\treturn fmt.Errorf(\"patching resource %s/%q: %w\", ns, name, err)\n\t\t}\n\t} else {\n\t\tlog.Entry(ctx).Debug(\"Patching\", name)\n\t\tif _, err := client.Resource(gvr).Patch(ctx, name, types.StrategicMergePatchType, p, metav1.PatchOptions{}); err != nil {\n\t\t\treturn fmt.Errorf(\"patching resource %q: %w\", name, err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\nfunc resolveNamespace(ns, kubeContext string) (string, error) {\n\tif ns != \"\" {","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/GoogleContainerTools/skaffold/blob/a1189de023efc32d4b8e11f395acc678aa555011/pkg/skaffold/deploy/label/labels.go#L98-L134","documentation":"For namespaced resources without an explicit namespace, updateRuntimeObject calls resolveNamespace, which reads the kubeconfig via kubectx.CurrentConfig to find the context's default namespace. This error wraps a failure to load the current kubeconfig configuration.","triggerScenarios":"A namespaced resource with empty namespace on both the object and the artifact, plus kubectx.CurrentConfig() failing — unreadable/missing kubeconfig or invalid MERGE/KUBECONFIG setup.","commonSituations":"Missing kubeconfig in CI while manifests omit `namespace:`; corrupted kubeconfig; KUBECONFIG merging multiple files where one is invalid.","solutions":["Set an explicit namespace in the manifest metadata so resolveNamespace is never invoked","Ensure kubeconfig is readable: `kubectl config view --minify` should succeed","Fix or regenerate the kubeconfig file(s) referenced by KUBECONFIG"],"exampleFix":"// before\nmetadata:\n  name: my-app\n// after\nmetadata:\n  name: my-app\n  namespace: default","handlingStrategy":"validation","validationCode":"if ns == \"\" {\n    ns = os.Getenv(\"POD_NAMESPACE\")\n    if ns == \"\" {\n        ns = \"default\"\n    }\n}","typeGuard":null,"tryCatchPattern":"ns, err := resolveNamespace(namespace, kubeContext)\nif err != nil {\n    return fmt.Errorf(\"no namespace on object and kubeconfig unreadable: %w\", err)\n}","preventionTips":["Always set metadata.namespace in manifests used by CI","Keep a valid kubeconfig wherever skaffold runs","Avoid malformed multi-file KUBECONFIG merges"],"tags":["kubernetes","namespace","kubeconfig"],"backgroundTag":"invalid-kubeconfig","analyzedSha":"a1189de023efc32d4b8e11f395acc678aa555011","analyzedAt":"2026-09-05T12:09:27.064Z","contentChangedAt":"2026-09-05T12:09:27.064Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}