derailed/k9s · warning
missing resource name in path %q
Error message
missing resource name in path %q
What it means
The selected path was non-empty but client.Namespaced(path) could not extract a resource name — the path is malformed, e.g. only a namespace ("myns") or a trailing-slash form ("myns/"). The name segment is required to build the kubectl edit target gvr.FQN(n).
Source
Thrown at internal/view/browser.go:561
return evt
}
b.Stop()
defer b.Start()
if err := editRes(b.app, b.GVR(), path); err != nil {
b.App().Flash().Err(err)
}
return nil
}
func editRes(app *App, gvr *client.GVR, path string) error {
if path == "" {
return fmt.Errorf("nothing selected %q", path)
}
ns, n := client.Namespaced(path)
if n == "" {
return fmt.Errorf("missing resource name in path %q", path)
}
if client.IsClusterScoped(ns) {
ns = client.BlankNamespace
}
if ok, err := app.Conn().CanI(ns, gvr, n, client.PatchAccess); !ok || err != nil {
return fmt.Errorf("current user can't edit resource %s", gvr)
}
args := make([]string, 0, 10)
args = append(args, "edit", gvr.FQN(n))
if ns != client.BlankNamespace {
args = append(args, "-n", ns)
}
if err := runK(app, &shellOpts{clear: true, args: args}); err != nil {
app.Flash().Errf("Edit command failed: %s", err)
}
return nilView on GitHub (pinned to 2d3ccc6ba2)
Solutions
- Inspect the selected row's Path column; fix the producer so it always sets path to ns/name (name from object meta.name).
- Skip edit (and other row actions) for non-resource rows such as grouping headers.
- If a custom column decorator builds the path, sanitize: strings.TrimSuffix(path, "/") and verify both segments non-empty.
Example fix
// before row.Path = ns // after row.Path = ns + "/" + name
Defensive patterns
Strategy: validation
Validate before calling
ns, n := client.Namespaced(path)
if n == "" {
return fmt.Errorf("refusing edit: no name in path %q", path)
} Try / catch
if err := editRes(app, gvr, path); err != nil && strings.Contains(err.Error(), "missing resource name") {
slog.Error("malformed selection path", "path", path)
} Prevention
- Always build row paths as ns + "/" + metadata.name at row-construction time.
- Add a shared helper isResourcePath(s string) bool checking two non-empty segments, and use it before row actions.
- Skip actions on grouping/header rows that have no name segment.
When it happens
Trigger: Path strings like "default/", "/", "ns-only", or paths with extra separators that make the name component empty. Produced by custom rows whose Path/ID column is populated from a field that lacks the name, or by a row representing a grouping/header node.
Common situations: Custom resource views where the ID column holds a namespace or label instead of ns/name; resources whose metadata.name is empty in the cached object; separators/dupes introduced by string joins in custom decorators.
Related errors
- nothing selected %q
- expecting cronjob resource
- expecting Deployment resource
- expecting ServiceAccount resource
- expecting a context factory
AI-assisted analysis of derailed/k9s@2d3ccc6ba2 (2026-08-15).
Data as JSON: /api/errors/41800e8495e25941.
Report an issue: GitHub.