{"record":{"id":"467959427485d345","repo":"nektos/act","slug":"invalid-device-specification-s","errorCode":null,"errorMessage":"invalid device specification: %s","messagePattern":"invalid device specification: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/container/docker_cli.go","lineNumber":1035,"sourceCode":"\tvar src, dst string\n\tpermissions := \"rwm\"\n\t// We expect 3 parts at maximum; limit to 4 parts to detect invalid options.\n\tarr := strings.SplitN(device, \":\", 4)\n\tswitch len(arr) {\n\tcase 3:\n\t\tpermissions = arr[2]\n\t\tfallthrough\n\tcase 2:\n\t\tif validDeviceMode(arr[1]) {\n\t\t\tpermissions = arr[1]\n\t\t} else {\n\t\t\tdst = arr[1]\n\t\t}\n\t\tfallthrough\n\tcase 1:\n\t\tsrc = arr[0]\n\tdefault:\n\t\treturn container.DeviceMapping{}, fmt.Errorf(\"invalid device specification: %s\", device)\n\t}\n\n\tif dst == \"\" {\n\t\tdst = src\n\t}\n\n\treturn container.DeviceMapping{\n\t\tPathOnHost:        src,\n\t\tPathInContainer:   dst,\n\t\tCgroupPermissions: permissions,\n\t}, nil\n}\n\n// validateDeviceCgroupRule validates a device cgroup rule string format\n// It will make sure 'val' is in the form:\n//\n//\t'type major:minor mode'\nfunc validateDeviceCgroupRule(val string) (string, error) {","sourceCodeStart":1017,"sourceCodeEnd":1053,"githubUrl":"https://github.com/nektos/act/blob/4f411281417e88660bea1c1a1749aa71ae0bd60f/pkg/container/docker_cli.go#L1017-L1053","documentation":"parseLinuxDevice splits a --device specification (host[:container[:mode]]) using SplitN with a limit of 4. A valid spec yields 1-3 parts; hitting the default branch means 4 or more colon-separated segments were found, which cannot be a valid device mapping.","triggerScenarios":"Passing a device string with 4+ colon-separated parts, e.g. --device /dev/foo:/dev/foo:rwm:extra or a Windows-style path like C:\\dev\\x:/dev/x:rwm on a Linux daemon.","commonSituations":"Typos with extra colons, copy-pasting Windows paths into --device on Linux, or concatenating two device specs into one flag.","solutions":["Count the colons: the spec must have at most three segments host:container:mode","Rewrite as --device /dev/foo:/dev/foo:rwm","Specify multiple devices with repeated --device flags instead of one string","For Windows paths on a Linux daemon, use POSIX-style device paths"],"exampleFix":"# before\n--device /dev/bus/usb/001/001:/dev/bus/usb/001/001:rwm:oops\n\n# after\n--device /dev/bus/usb/001/001:/dev/bus/usb/001/001:rwm","handlingStrategy":"validation","validationCode":"// Go: reject device specs with more than 3 colon segments up front\nfunc validDeviceShape(s string) bool { return strings.Count(s, \":\") <= 2 }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cap device specs at host:container:mode","One device per --device flag","Avoid Windows drive-letter paths on Linux daemons"],"tags":["docker","device-mapping","flag-parsing","validation"],"backgroundTag":null,"analyzedSha":"4f411281417e88660bea1c1a1749aa71ae0bd60f","analyzedAt":"2026-08-15T09:19:46.307Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}