{"record":{"id":"519f1a600f15a1c1","repo":"docker/cli","slug":"network-name-id-is-not-specified","errorCode":null,"errorMessage":"network name/id is not specified","messagePattern":"network name/id is not specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"opts/network.go","lineNumber":114,"sourceCode":"\t\t\t\tif netOpt.DriverOpts == nil {\n\t\t\t\t\tnetOpt.DriverOpts = make(map[string]string)\n\t\t\t\t}\n\t\t\t\tnetOpt.DriverOpts[key] = val\n\t\t\tcase gwPriorityOpt:\n\t\t\t\tnetOpt.GwPriority, err = strconv.Atoi(val)\n\t\t\t\tif err != nil {\n\t\t\t\t\tvar numErr *strconv.NumError\n\t\t\t\t\tif errors.As(err, &numErr) {\n\t\t\t\t\t\terr = numErr.Err\n\t\t\t\t\t}\n\t\t\t\t\treturn fmt.Errorf(\"invalid gw-priority (%s): %w\", val, err)\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\treturn errors.New(\"invalid field key \" + key)\n\t\t\t}\n\t\t}\n\t\tif len(netOpt.Target) == 0 {\n\t\t\treturn errors.New(\"network name/id is not specified\")\n\t\t}\n\t} else {\n\t\tnetOpt.Target = value\n\t}\n\tn.options = append(n.options, netOpt)\n\treturn nil\n}\n\n// Type returns the type of this option\nfunc (*NetworkOpt) Type() string {\n\treturn \"network\"\n}\n\n// Value returns the networkopts\nfunc (n *NetworkOpt) Value() []NetworkAttachmentOpts {\n\treturn n.options\n}\n","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/docker/cli/blob/4f84911bfe8811e9b028e4b1fee8e7510be79387/opts/network.go#L96-L132","documentation":"Returned by NetworkOpt.Set (opts/network.go:114) when the long syntax is detected (the value matches the key=value pattern) but no 'name=' field is provided, leaving the network Target empty. The long syntax requires at least a name (or network ID) to identify which network to attach to.","triggerScenarios":"A --network value is parsed as long syntax (contains key=value pairs) but none of the fields is 'name=...', so netOpt.Target remains empty after processing all fields. For example: '--network ip=1.2.3.4' or '--network alias=web'.","commonSituations":"Forgetting to include the 'name=' field when using long syntax, or assuming the network name can be inferred from other options.","solutions":["Add a 'name=<network-name-or-id>' field to the --network long syntax value.","If you only want to specify a network by name without options, use short syntax: '--network mynet'."],"exampleFix":"// before: long syntax without name\n// docker run --network ip=1.2.3.4 nginx\n\n// after: include name\n// docker run --network name=mynet,ip=1.2.3.4 nginx","handlingStrategy":"validation","validationCode":"func validateNetworkHasName(spec string) error {\n    // Long syntax is detected by the regex in NetworkOpt.Set\n    matched, _ := regexp.MatchString(`\\w+=\\w+(,\\w+=\\w+)*`, spec)\n    if matched && !strings.Contains(strings.ToLower(spec), \"name=\") {\n        return fmt.Errorf(\"long syntax --network requires a 'name=<network>' field\")\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":"if err := networkOpt.Set(value); err != nil {\n    if err.Error() == \"network name/id is not specified\" {\n        return fmt.Errorf(\"add 'name=<network-name-or-id>' to the --network spec\")\n    }\n    return err\n}","preventionTips":["Always include 'name=<network>' when using --network long syntax.","Use short syntax ('--network mynet') when no additional options are needed.","Validate network specs before passing to NetworkOpt.Set."],"tags":["network","validation","cli-flag"],"backgroundTag":null,"analyzedSha":"4f84911bfe8811e9b028e4b1fee8e7510be79387","analyzedAt":"2026-08-07T12:15:29.814Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}