derailed/k9s · warning

you must provide a selection

Error message

you must provide a selection

What it means

Returned by `Deploy.logOptions` (internal/view/dp.go:~55) when the deployments table has no selected item. The logs shortcut must resolve a concrete deployment to build pod log options from its pod template; an empty selection aborts with this message.

Source

Thrown at internal/view/dp.go:55

			),
		),
	)
	d.AddBindKeysFn(d.bindKeys)
	d.GetTable().SetEnterFn(d.showPods)

	return &d
}

func (d *Deploy) bindKeys(aa *ui.KeyActions) {
	aa.Bulk(ui.KeyMap{
		ui.KeyZ: ui.NewKeyAction("ReplicaSets", d.replicaSetsCmd, true),
	})
}

func (d *Deploy) logOptions(prev bool) (*dao.LogOptions, error) {
	path := d.GetTable().GetSelectedItem()
	if path == "" {
		return nil, errors.New("you must provide a selection")
	}
	dp, err := d.getInstance(path)
	if err != nil {
		return nil, err
	}

	return podLogOptions(d.App(), path, prev, &dp.ObjectMeta, &dp.Spec.Template.Spec), nil
}

func (d *Deploy) replicaSetsCmd(evt *tcell.EventKey) *tcell.EventKey {
	dName := d.GetTable().GetSelectedItem()
	if dName == "" {
		return evt
	}
	dp, err := d.getInstance(dName)
	if err != nil {
		d.App().Flash().Err(err)
		return nil

View on GitHub (pinned to 2d3ccc6ba2)

Solutions

  1. Ensure a deployment row is highlighted before pressing the logs key
  2. Clear filters (`/` + Esc) that may hide all rows
  3. If the list is empty, switch to a namespace that actually has deployments (check with `kubectl get deploy -A`)
  4. Select a pod directly in the pod view if you only need pod logs
Defensive patterns

Strategy: validation

Validate before calling

if d.GetTable().GetSelectedItem() == "" {
    d.App().Flash().Warnf("You must select a deployment")
    return nil
}

Prevention

When it happens

Trigger: Pressing the logs key on the deployments view with no row selected — empty deployment list (filtered namespace has none), active filter hiding all rows, or no highlight at keypress time.

Common situations: Namespace has zero deployments; user applies a label filter that excludes everything; selection lost right after context/namespace switch.

Related errors


AI-assisted analysis of derailed/k9s@2d3ccc6ba2 (2026-08-15). Data as JSON: /api/errors/f9418e0e7adc30be. Report an issue: GitHub.