{"record":{"id":"6f7dfa068c79e46d","repo":"slackhq/nebula","slug":"invalid-port-s-w","errorCode":null,"errorMessage":"invalid port: %s: %w","messagePattern":"invalid port: (.+?): %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"calculated_remote.go","lineNumber":156,"sourceCode":"\t\treturn nil, fmt.Errorf(\"invalid mask (type %T): %v\", rawValue, rawValue)\n\t}\n\tmaskCidr, err := netip.ParsePrefix(rawMask)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid mask: %s\", rawMask)\n\t}\n\n\tvar port int\n\trawValue = rawMap[\"port\"]\n\tif rawValue == nil {\n\t\treturn nil, fmt.Errorf(\"missing port: %v\", rawMap)\n\t}\n\tswitch v := rawValue.(type) {\n\tcase int:\n\t\tport = v\n\tcase string:\n\t\tport, err = strconv.Atoi(v)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"invalid port: %s: %w\", v, err)\n\t\t}\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"invalid port (type %T): %v\", rawValue, rawValue)\n\t}\n\n\treturn newCalculatedRemote(cidr, maskCidr, port)\n}\n","sourceCodeStart":138,"sourceCodeEnd":164,"githubUrl":"https://github.com/slackhq/nebula/blob/dd8f660c0ac37903ec4080ca4d3c861ba9342ceb/calculated_remote.go#L138-L164","documentation":"This error is returned by newCalculatedRemotesEntryFromConfig when the 'port' value in a calculated_remotes entry is a string that cannot be converted to an integer with strconv.Atoi. The string form is allowed in YAML, but it must contain only digits representing a valid port number.","triggerScenarios":"Setting port as a non-numeric string in a calculated_remotes entry, e.g. port: \"4242x\", port: \"port\", or port: \"\" — Atoi fails and the underlying strconv error is wrapped.","commonSituations":"Typos in the port number, accidental leftover placeholder text, or locale/whitespace characters inside quoted strings in the YAML config.","solutions":["Set the port to a bare integer (port: 4242) or a clean numeric string (port: \"4242\")","Strip whitespace, quotes, or non-digit characters from the port value","Ensure the number is within the valid port range (1-65535)"],"exampleFix":"// before\ncalculated_remotes:\n  - mask: 10.0.0.0/8\n    port: \"44x2\"\n// after\ncalculated_remotes:\n  - mask: 10.0.0.0/8\n    port: 4242","handlingStrategy":"validation","validationCode":"func validPortString(v string) bool {\n    n, err := strconv.Atoi(strings.TrimSpace(v))\n    return err == nil && n > 0 && n <= 65535\n}","typeGuard":"func asPortString(raw any) (string, bool) {\n    s, ok := raw.(string)\n    if !ok || !validPortString(s) {\n        return \"\", false\n    }\n    return s, true\n}","tryCatchPattern":"if err != nil {\n    var numErr *strconv.NumError\n    if errors.As(err, &numErr) || strings.Contains(err.Error(), \"invalid port\") {\n        log.Fatalf(\"calculated_remotes port must be numeric: %v\", err)\n    }\n    return err\n}","preventionTips":["Prefer unquoted integer ports (port: 4242) in YAML","Trim whitespace and strip comments/units from port strings","Range-check ports 1-65535 during config linting"],"tags":["config","yaml","port","parsing"],"backgroundTag":"invalid-config-value","analyzedSha":"dd8f660c0ac37903ec4080ca4d3c861ba9342ceb","analyzedAt":"2026-09-03T11:13:55.444Z","contentChangedAt":"2026-09-03T11:13:55.444Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}