{"record":{"id":"bcd46a835c855eea","repo":"derailed/k9s","slug":"failed-to-process-field-selector-template-w","errorCode":null,"errorMessage":"failed to process field selector template: %w","messagePattern":"failed to process field selector template: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/view/custom_jump.go","lineNumber":79,"sourceCode":"\t\t}\n\t\tlabelSel, labelErr = labels.Parse(labelStr)\n\t\tif labelErr != nil {\n\t\t\treturn fmt.Errorf(\"invalid label selector: %w\", labelErr)\n\t\t}\n\t}\n\n\t// Set label selector if we have one\n\tif labelSel != nil {\n\t\tv.SetLabelSelector(labelSel, true)\n\t}\n\n\t// Build field selector if specified\n\tvar fieldSel string\n\tif rule.FieldSelector != \"\" {\n\t\tvar fieldErr error\n\t\tfieldSel, fieldErr = applyTemplate(rule.FieldSelector, sourceObj)\n\t\tif fieldErr != nil {\n\t\t\treturn fmt.Errorf(\"failed to process field selector template: %w\", fieldErr)\n\t\t}\n\t}\n\n\t// Set up the context for the jump\n\tv.SetContextFn(func(ctx context.Context) context.Context {\n\t\tif fieldSel != \"\" {\n\t\t\tctx = context.WithValue(ctx, internal.KeyFields, fieldSel)\n\t\t}\n\t\treturn ctx\n\t})\n\n\t// Jump to the target namespace if needed\n\tif targetNS != \"\" && targetNS != client.NamespaceAll && targetNS != client.ClusterScope {\n\t\tif err := app.Config.SetActiveNamespace(targetNS); err != nil {\n\t\t\tslog.Error(\"Unable to set active namespace during custom jump\", slogs.Error, err)\n\t\t}\n\t}\n","sourceCodeStart":61,"sourceCodeEnd":97,"githubUrl":"https://github.com/derailed/k9s/blob/2d3ccc6ba2ce98c3781bfc441bb3e884f072774f/internal/view/custom_jump.go#L61-L97","documentation":"Same template pipeline as the label selector, but for the jump rule's fieldSelector: applyTemplate(rule.FieldSelector, sourceObj) failed while rendering. The cause (%w) is the template engine error, usually a missing field in the source object map.","triggerScenarios":"A rule like fieldSelector: \"metadata.name={{ .metadata.name }}\" where a referenced path (e.g. .spec.nodeName) does not exist on the fetched source object.","commonSituations":"Field selectors written for pods reused on other kinds; CRDs whose spec lacks the referenced field; objects created by older API versions without the field.","solutions":["Check the source object's YAML for the referenced field path","Use only universally present fields (metadata.name, metadata.namespace) in fieldSelector templates","Drop the fieldSelector from the rule if it is not needed — it is optional"],"exampleFix":"// before\nfieldSelector: \"spec.nodeName={{ .spec.nodeName }}\"  // fails on objects without spec.nodeName\n// after\nfieldSelector: \"metadata.namespace={{ .metadata.namespace }}\"","handlingStrategy":"validation","validationCode":"// confirm every referenced field exists on a sample object\nobj, _ := fetchResourceObject(app, sourceGVR, sourcePath)\nif _, err := applyTemplate(rule.FieldSelector, obj); err != nil {\n    return fmt.Errorf(\"fieldSelector template references a missing field: %w\", err)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only metadata.name and metadata.namespace in field-selector templates — the only fields every object carries","Verify field names against the API schema; CRD fields vary wildly between versions","Omit fieldSelector entirely when not needed; it is optional"],"tags":["kubernetes","k9s","template","field-selector","config"],"backgroundTag":null,"analyzedSha":"2d3ccc6ba2ce98c3781bfc441bb3e884f072774f","analyzedAt":"2026-08-15T16:09:14.432Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}