{"record":{"id":"7169e48176271a3c","repo":"derailed/k9s","slug":"no-component-found-for-s","errorCode":null,"errorMessage":"no component found for %s","messagePattern":"no component found for (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/view/command.go","lineNumber":370,"sourceCode":"func (c *Command) exec(p *cmd.Interpreter, gvr *client.GVR, comp model.Component, clearStack, pushCmd bool) (err error) {\n\tdefer func() {\n\t\tif e := recover(); e != nil {\n\t\t\tslog.Error(\"Failure detected during command exec\", slogs.Error, e)\n\t\t\tc.app.Content.Dump()\n\t\t\tslog.Debug(\"Dumping history buffer\", slogs.CmdHist, c.app.cmdHistory.List())\n\t\t\tslog.Error(\"Dumping stack\", slogs.Stack, string(debug.Stack()))\n\n\t\t\tci := cmd.NewInterpreter(podCmd)\n\t\t\tcurrentCommand, ok := c.app.cmdHistory.Top()\n\t\t\tif ok {\n\t\t\t\tci = ci.Reset(currentCommand, \"\")\n\t\t\t}\n\t\t\terr = c.run(ci, \"\", true, true)\n\t\t}\n\t}()\n\n\tif comp == nil {\n\t\treturn fmt.Errorf(\"no component found for %s\", gvr)\n\t}\n\tcomp.SetCommand(p)\n\n\tif clearStack {\n\t\tv := contextRX.ReplaceAllString(p.GetLine(), \"\")\n\t\tc.app.Config.SetActiveView(v)\n\t}\n\tif err := c.app.inject(comp, clearStack); err != nil {\n\t\treturn err\n\t}\n\tif pushCmd {\n\t\tc.app.cmdHistory.Push(p.GetLine())\n\t}\n\tslog.Debug(\"History (exec)\", slogs.Stack, strings.Join(c.app.cmdHistory.List(), \"|\"))\n\n\treturn\n}\n","sourceCodeStart":352,"sourceCodeEnd":388,"githubUrl":"https://github.com/derailed/k9s/blob/2d3ccc6ba2ce98c3781bfc441bb3e884f072774f/internal/view/command.go#L352-L388","documentation":"The command executed and resolved to a GVR, but the component factory returned nil — no viewer is registered that can display this GVR. The registry (customViewers plus generic browser fallback) had no entry for the resource, so there is no component to inject into the UI stack.","triggerScenarios":"A GVR string that resolves via alias but has no viewer mapping — malformed/custom group-version-resource that bypassed customViewers registration; a programmatic call to the exec/inject path with a GVR never registered; race where the viewers map is not yet initialized at startup.","commonSituations":"Custom resources expected to render generically but hitting a restricted path; forks adding GVRs without registering viewers; version changes to the viewer registry; invoking internal APIs directly rather than through the command layer.","solutions":["Use the normal command path (alias -> browser) which always has the generic browser fallback, instead of calling the component-inject path with raw GVRs.","Register a custom viewer for the GVR in customViewers (or the user custom-view config) before navigating to it.","Verify the GVR string (group/version/resource) is exactly what discovery reports.","If it happens for standard resources on startup, reconnect/restart so the viewer registry completes initialization."],"exampleFix":"// before: rely on registry for unknown gvr\ncomp := componentFor(gvr) // may be nil\n\n// after: register a fallback viewer first\ncustomViewers[*gvr] = MetaViewer{viewerFn: func(g *client.GVR) ResourceViewer { return NewBrowser(g) }}","handlingStrategy":"validation","validationCode":"if comp := componentFor(gvr); comp == nil {\n    return fmt.Errorf(\"no viewer for %s — register one or use the generic browser\", gvr)\n}\ncomp.SetCommand(p)","typeGuard":"func hasViewer(gvr *client.GVR) bool {\n    _, ok := customViewers[*gvr]\n    return ok || hasGenericFallback(gvr)\n}","tryCatchPattern":"if err := c.exec(p, gvr, comp, clearStack, pushCmd); err != nil {\n    if strings.Contains(err.Error(), \"no component found\") {\n    slog.Error(\"missing viewer registration\", \"gvr\", gvr)\n    }\n}","preventionTips":["Register a customViewer (or rely on the generic browser path) for every GVR reachable via commands.","Test command-to-component wiring for each GVR you add.","Initialize the viewer registry before the command interpreter accepts input."],"tags":["go","viewer-registry","navigation","startup"],"backgroundTag":null,"analyzedSha":"2d3ccc6ba2ce98c3781bfc441bb3e884f072774f","analyzedAt":"2026-08-15T16:09:14.432Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}