{"record":{"id":"aae9ec481c799621","repo":"amir20/dozzle","slug":"unknown-action-s-aae9ec","errorCode":null,"errorMessage":"unknown action: %s","messagePattern":"unknown action: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/docker/client.go","lineNumber":196,"sourceCode":"\n}\n\nfunc (d *DockerClient) ContainerActions(ctx context.Context, action container.ContainerAction, containerID string) error {\n\tswitch action {\n\tcase container.Start:\n\t\t_, err := d.cli.ContainerStart(ctx, containerID, client.ContainerStartOptions{})\n\t\treturn err\n\tcase container.Stop:\n\t\t_, err := d.cli.ContainerStop(ctx, containerID, client.ContainerStopOptions{})\n\t\treturn err\n\tcase container.Restart:\n\t\t_, err := d.cli.ContainerRestart(ctx, containerID, client.ContainerRestartOptions{})\n\t\treturn err\n\tcase container.Remove:\n\t\t_, err := d.cli.ContainerRemove(ctx, containerID, client.ContainerRemoveOptions{})\n\t\treturn err\n\tdefault:\n\t\treturn fmt.Errorf(\"unknown action: %s\", action)\n\t}\n}\n\nfunc (d *DockerClient) ImagePull(ctx context.Context, imageName string) (io.ReadCloser, error) {\n\treturn d.cli.ImagePull(ctx, imageName, client.ImagePullOptions{})\n}\n\n// ImageRepoDigests returns the \"repo@sha256:...\" digests recorded for a\n// locally available image. An image built locally has none, which is what\n// makes it impossible to check for updates. The repository is kept because an\n// image can carry digests for several repositories, and only the one being\n// checked is comparable.\nfunc (d *DockerClient) ImageRepoDigests(ctx context.Context, imageID string) ([]string, error) {\n\tresult, err := d.cli.ImageInspect(ctx, imageID)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/amir20/dozzle/blob/d9463cbe21874e44ab79db6fa63e746ca7d22928/internal/docker/client.go#L178-L214","documentation":"ContainerActions dispatches on a container.Action enum and executes the matching Docker API call. If the action string is not one of the known cases (start, stop, restart, remove, etc.), it falls through to this default error.","triggerScenarios":"Calling ContainerActions with an action value outside the switch, e.g. ContainerActions(ctx, id, \"pause\") when pause is not implemented, or a typo/empty string for the action.","commonSituations":"New Docker action added upstream in the UI before the docker client implements it; test code passing an arbitrary string; a caller constructing an action from user input without validating it.","solutions":["Use only the container.Action constants the switch supports (check the full switch in client.go for the current set)","If you need the missing action, add a case to the switch calling the corresponding client method","Validate/normalize user-supplied actions against the enum before calling"],"exampleFix":"// before\nerr := client.ContainerActions(ctx, id, \"pause\")\n// after\nswitch action {\ncase container.Start, container.Stop, container.Restart, container.Remove:\n    err = client.ContainerActions(ctx, id, action)\ndefault:\n    err = fmt.Errorf(\"unsupported action %q\", action)\n}","handlingStrategy":"type-guard","validationCode":"valid := map[container.Action]bool{\n    container.Start: true, container.Stop: true,\n    container.Restart: true, container.Remove: true,\n}\nif !valid[action] {\n    return fmt.Errorf(\"unsupported action %q\", action)\n}","typeGuard":"func isSupportedAction(a container.Action) bool {\n    switch a {\n    case container.Start, container.Stop, container.Restart, container.Remove:\n        return true\n    }\n    return false\n}","tryCatchPattern":"if err := client.ContainerActions(ctx, id, action); err != nil {\n    if strings.HasPrefix(err.Error(), \"unknown action\") {\n        return fmt.Errorf(\"action %q not supported by this client\", action)\n    }\n    return err\n}","preventionTips":["Only use the container.Action enum constants, never raw strings","Keep the UI/action enum in sync with the docker client switch","Add a test covering every enum member against ContainerActions"],"tags":["docker","container-actions","enum","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"d9463cbe21874e44ab79db6fa63e746ca7d22928","analyzedAt":"2026-09-07T10:08:55.855Z","contentChangedAt":"2026-09-07T10:08:55.855Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}