{"record":{"id":"33043fb1c546bfdb","repo":"gastownhall/beads","slug":"externaldoltconfig-port-d-out-of-range-1-65535","errorCode":null,"errorMessage":"ExternalDoltConfig: Port %d out of range [1, 65535]","messagePattern":"ExternalDoltConfig: Port (.+?) out of range \\[1, 65535\\]","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/configfile/external_dolt_config.go","lineNumber":56,"sourceCode":"\nfunc (c ExternalDoltConfig) Validate() error {\n\thasHost := c.Host != \"\"\n\thasPort := c.Port != 0\n\thasSocket := c.Socket != \"\"\n\n\tswitch {\n\tcase hasSocket && (hasHost || hasPort):\n\t\treturn errors.New(\"ExternalDoltConfig: set either Socket OR (Host, Port), not both\")\n\tcase !hasSocket && !hasHost && !hasPort:\n\t\treturn errors.New(\"ExternalDoltConfig: must set Socket or (Host, Port)\")\n\tcase hasHost && !hasPort:\n\t\treturn errors.New(\"ExternalDoltConfig: Host requires Port\")\n\tcase !hasHost && hasPort:\n\t\treturn errors.New(\"ExternalDoltConfig: Port requires Host\")\n\t}\n\n\tif hasHost && (c.Port < 1 || c.Port > 65535) {\n\t\treturn fmt.Errorf(\"ExternalDoltConfig: Port %d out of range [1, 65535]\", c.Port)\n\t}\n\n\tif hasSocket && !filepath.IsAbs(c.Socket) {\n\t\treturn fmt.Errorf(\"ExternalDoltConfig: Socket %q is not absolute\", c.Socket)\n\t}\n\n\tswitch {\n\tcase c.TLSCert != \"\" && c.TLSKey == \"\":\n\t\treturn errors.New(\"ExternalDoltConfig: TLSCert set without TLSKey\")\n\tcase c.TLSCert == \"\" && c.TLSKey != \"\":\n\t\treturn errors.New(\"ExternalDoltConfig: TLSKey set without TLSCert\")\n\t}\n\n\tif c.TLSCert != \"\" && !filepath.IsAbs(c.TLSCert) {\n\t\treturn fmt.Errorf(\"ExternalDoltConfig: TLSCert %q is not absolute\", c.TLSCert)\n\t}\n\tif c.TLSKey != \"\" && !filepath.IsAbs(c.TLSKey) {\n\t\treturn fmt.Errorf(\"ExternalDoltConfig: TLSKey %q is not absolute\", c.TLSKey)","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/configfile/external_dolt_config.go#L38-L74","documentation":"ExternalDoltConfig.Validate() checks the external dolt sql-server connection settings. When Host is set, Port must also be set and lie within [1, 65535]; a host with an out-of-range port (negative, zero handled earlier, or >65535) fails validation with this message before any connection attempt.","triggerScenarios":"Constructing ExternalDoltConfig or calling NewExternalDoltServer / NewExternalDoltServerUOWProvider / buildProxiedServerClientInfo with Host non-empty and Port < 1 or > 65535 — e.g. Port parsed from a bad env var, a config typo like 655360, or int overflow from an unparsed string (Port defaulting to a sentinel like -1).","commonSituations":"Typo in dolt_server_port in metadata.json or a BEADS_* env var; pasting an HTTPS URL port (e.g. 44300 typo); leaving a -1 placeholder; copy-pasting a port above 65535.","solutions":["Set Port to a valid TCP port 1-65535 (default Dolt server port is 3307)","Check the port value in metadata.json (dolt_server_port) and any BEADS_* env override for typos","If the port is parsed from a string, validate with strconv.Atoi and range-check before assigning","If you only have a host and no port, either add the correct port or switch to Socket-only configuration"],"exampleFix":"// before\ncfg := configfile.ExternalDoltConfig{Host: \"dolt.internal\", Port: 99999}\n// after\ncfg := configfile.ExternalDoltConfig{Host: \"dolt.internal\", Port: 3307}\nif err := cfg.Validate(); err != nil { return err }","handlingStrategy":"validation","validationCode":"func validPort(p int) bool { return p >= 1 && p <= 65535 }\n// before building ExternalDoltConfig:\nif host != \"\" && !validPort(port) {\n\treturn fmt.Errorf(\"port %d out of range for host %s\", port, host)\n}","typeGuard":"func hasValidHostPort(c configfile.ExternalDoltConfig) bool {\n\treturn c.Host != \"\" && c.Port >= 1 && c.Port <= 65535\n}","tryCatchPattern":"cfg := configfile.ExternalDoltConfig{Host: host, Port: port}\nif err := cfg.Validate(); err != nil {\n\tif strings.Contains(err.Error(), \"out of range\") {\n\t\treturn fmt.Errorf(\"fix dolt_server_port in metadata.json/env: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Range-check any port parsed from env/config strings (1-65535) before use","Use the documented default (3307) when unsure","Validate the full ExternalDoltConfig with Validate() at startup, before dialing","Avoid sentinel values like -1 leaking into Port from unset-variable handling"],"tags":["validation","config","dolt","network","port"],"backgroundTag":"invalid-port-config","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}