derailed/k9s · error
failed to inject target view: %w
Error message
failed to inject target view: %w
What it means
The jump rule was fully processed (source fetched, selectors built, target view constructed, namespace switched) and the final step app.inject(v, false) failed. inject pushes the new viewer onto k9s' page stack; failure means the app refused the view — most often because the app is shutting down or the view stack is in an inconsistent state. This is an internal/rare failure, not a config syntax problem.
Source
Thrown at internal/view/custom_jump.go:100
// Set up the context for the jump
v.SetContextFn(func(ctx context.Context) context.Context {
if fieldSel != "" {
ctx = context.WithValue(ctx, internal.KeyFields, fieldSel)
}
return ctx
})
// Jump to the target namespace if needed
if targetNS != "" && targetNS != client.NamespaceAll && targetNS != client.ClusterScope {
if err := app.Config.SetActiveNamespace(targetNS); err != nil {
slog.Error("Unable to set active namespace during custom jump", slogs.Error, err)
}
}
// Inject the new view
if err := app.inject(v, false); err != nil {
return fmt.Errorf("failed to inject target view: %w", err)
}
return nil
}
// fetchResourceObject retrieves the full resource object for templating.
func fetchResourceObject(app *App, gvr *client.GVR, path string) (map[string]any, error) {
accessor, err := dao.AccessorFor(app.factory, gvr)
if err != nil {
return nil, err
}
o, err := accessor.Get(context.Background(), path)
if err != nil {
return nil, err
}
u, ok := o.(*unstructured.Unstructured)View on GitHub (pinned to 2d3ccc6ba2)
Solutions
- Simply retry the jump once the UI is idle
- Avoid triggering jumps during context switches or shutdown
- If it reproduces reliably for one rule, capture k9s logs and report — the wrapped error identifies the inject failure
Defensive patterns
Strategy: try-catch
Try / catch
if err := customJump(app, gvr, path, rule); err != nil {
if errors.Is(err, errViewInjection) || strings.Contains(err.Error(), "failed to inject target view") {
// transient navigation failure — safe to retry once the UI settles
app.Flash().Errf("jump failed, retry: %v", err)
}
} Prevention
- Trigger jumps one at a time; do not stack navigations while a jump is in flight
- Avoid jumping during context switches or quit
- Capture k9s logs when it reproduces — the wrapped error names the inject failure
When it happens
Trigger: Triggering a custom jump at the same moment the app is quitting or another navigation/inject is in flight; race between queued UI updates and view injection.
Common situations: Fast keypresses queuing a jump while the previous navigation runs; jumping right after :quit or context switch; very rare timing-dependent states in custom jump handling.
Related errors
- node is cordoned
- namespace not ready
- expecting a switchable resource
- expecting a switchable resource
- no node assigned
AI-assisted analysis of derailed/k9s@2d3ccc6ba2 (2026-08-15).
Data as JSON: /api/errors/3029b398a7e4520b.
Report an issue: GitHub.