slimtoolkit/slim · error

unknown container type

Error message

unknown container type

What it means

waitForContainer polls container statuses by type: init, standard, or ephemeral. The switch over the container type has no matching case, so it fails with 'unknown container type'. This is an internal invariant violation — the container type value was not one of ctInit/ctStandard/ctEphemeral.

Source

Thrown at pkg/app/master/command/debug/handle_kubernetes_runtime.go:1032

	isContainerRunning := func() (bool, error) {
		pod, err := api.CoreV1().Pods(nsName).Get(ctx, podName, metav1.GetOptions{})
		if err != nil {
			return false, err
		}

		switch pod.Status.Phase {
		case corev1.PodRunning:
			var statuses []corev1.ContainerStatus
			switch containerType {
			case ctInit:
				statuses = pod.Status.InitContainerStatuses
			case ctStandard:
				statuses = pod.Status.ContainerStatuses
			case ctEphemeral:
				statuses = pod.Status.EphemeralContainerStatuses
			default:
				return false, fmt.Errorf("unknown container type")
			}

			logger.Tracef("waitForContainer: statuses (%d)", len(statuses))
			for _, status := range statuses {
				if status.Name == containerName {
					if status.State.Running != nil {
						logger.Tracef("waitForContainer: RUNNING - %s/%s/%s[%s]", nsName, podName, containerName, containerType)

						if xc != nil {
							xc.Out.Info("wait.for.container.done",
								ovars{
									"state":      "RUNNING",
									"name":       containerName,
									"pod":        podName,
									"namespace":  nsName,
									"type":       containerType,
									"start_time": fmt.Sprintf("%v", status.State.Running.StartedAt),
									"id":         status.ContainerID,

View on GitHub (pinned to 81940d17fa)

Solutions

  1. Update to the latest docker-slim version; if a recent release introduced a new container type, this may already be patched.
  2. Re-run the command to rule out a transient bad state; if reproducible, file a bug with the exact command and k8s setup.
  3. As a workaround, specify the target container explicitly so the code path takes a known container type.
  4. Inspect the source switch (handle_kubernetes_runtime.go:~1025) and extend it to handle the new type if you build from source.

Example fix

// before
case ctEphemeral:
    statuses = pod.Status.EphemeralContainerStatuses
default:
    return false, fmt.Errorf("unknown container type")
// after
case ctEphemeral:
    statuses = pod.Status.EphemeralContainerStatuses
case ctNewType:
    statuses = pod.Status.ContainerStatuses
default:
    return false, fmt.Errorf("unknown container type: %v", ct)
Defensive patterns

Strategy: try-catch

Try / catch

if err := runDebug(target); err != nil && strings.Contains(err.Error(), "unknown container type") {
    // internal bug: report to docker-slim with command + version; pin to a known-good release
}

Prevention

When it happens

Trigger: HandleKubernetesRuntime's waitForContainer helper receives a container type outside the known enum (e.g., zero-value or corrupted parameter) while waiting for a container to reach Running state.

Common situations: A new container type constant added to the codebase without extending waitForContainer's switch; a refactor that changed the type values; passing an unset/empty container-type variable.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of slimtoolkit/slim@81940d17fa (2026-08-31). Data as JSON: /api/errors/5e17f6de7c62b825. Report an issue: GitHub.