{"record":{"id":"30bef3d58fe43ed0","repo":"nats-io/nats-server","slug":"gateway-in-the-list-d-has-no-name","errorCode":null,"errorMessage":"gateway in the list %d has no name","messagePattern":"gateway in the list (.+?) has no name","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/gateway.go","lineNumber":321,"sourceCode":"}\n\n// Ensure that gateway is properly configured.\nfunc validateGatewayOptions(o *Options) error {\n\tif o.Gateway.Name == _EMPTY_ && o.Gateway.Port == 0 {\n\t\treturn nil\n\t}\n\tif o.Gateway.Name == _EMPTY_ {\n\t\treturn errors.New(\"gateway has no name\")\n\t}\n\tif strings.Contains(o.Gateway.Name, \" \") {\n\t\treturn ErrGatewayNameHasSpaces\n\t}\n\tif o.Gateway.Port == 0 {\n\t\treturn fmt.Errorf(\"gateway %q has no port specified (select -1 for random port)\", o.Gateway.Name)\n\t}\n\tfor i, g := range o.Gateway.Gateways {\n\t\tif g.Name == _EMPTY_ {\n\t\t\treturn fmt.Errorf(\"gateway in the list %d has no name\", i)\n\t\t}\n\t\tif len(g.URLs) == 0 {\n\t\t\treturn fmt.Errorf(\"gateway %q has no URL\", g.Name)\n\t\t}\n\t}\n\tif err := validatePinnedCerts(o.Gateway.TLSPinnedCerts); err != nil {\n\t\treturn fmt.Errorf(\"gateway %q: %v\", o.Gateway.Name, err)\n\t}\n\treturn nil\n}\n\n// Computes a hash of 6 characters for the name.\n// This will be used for routing of replies.\nfunc getGWHash(name string) []byte {\n\treturn []byte(getHashSize(name, gwHashLen))\n}\n\nfunc getOldHash(name string) []byte {","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/gateway.go#L303-L339","documentation":"Every remote gateway listed under o.Gateway.Gateways must have a name; an empty name cannot be used to compute the 6-character gateway routing hash or to address the remote cluster. The error reports the index in the list so the offender can be located.","triggerScenarios":"A gateway { gateways: [ { urls: [...] } ] } entry missing the name field, or programmatically a RemoteGatewayOpts with Name == \"\" inside Options.Gateway.Gateways during validateOptions at startup.","commonSituations":"Hand-edited config dropped the name key, generated config left a name placeholder empty, or constructing []RemoteGatewayOpts in Go code without setting Name.","solutions":["Add gateway { name: \"B\" } to the offending gateways entry (index given in the message)","In code, set RemoteGatewayOpts.Name to the remote cluster's exact name","Validate the rendered config file (nats-server -t) before deploy","Ensure config generators emit non-empty names for every gateways entry"],"exampleFix":"// before\ngateways: [ { urls: [\"nats://b:7222\"] } ]\n// after\ngateways: [ { name: \"B\", urls: [\"nats://b:7222\"] } ]","handlingStrategy":"validation","validationCode":"for i, g := range opts.Gateway.Gateways {\n    if g.Name == \"\" { return fmt.Errorf(\"gateway entry %d missing name\", i) }\n}","typeGuard":null,"tryCatchPattern":"err := server.ValidateOptions(opts)\nif err != nil && strings.Contains(err.Error(), \"has no name\") {\n    // parse index from message and fix that gateways entry\n}","preventionTips":["Keep name and urls together in every gateways block","Run nats-server -t on generated configs before deploy","Reject empty names at config-generation time"],"tags":["config","gateway","validation"],"backgroundTag":"missing-config-field","analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}