{"record":{"id":"888a5aa2c022b289","repo":"slackhq/nebula","slug":"invalid-port-type-t-v","errorCode":null,"errorMessage":"invalid port (type %T): %v","messagePattern":"invalid port \\(type %T\\): (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"calculated_remote.go","lineNumber":159,"sourceCode":"\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":141,"sourceCodeEnd":164,"githubUrl":"https://github.com/slackhq/nebula/blob/dd8f660c0ac37903ec4080ca4d3c861ba9342ceb/calculated_remote.go#L141-L164","documentation":"This error is returned by newCalculatedRemotesEntryFromConfig when the 'port' value in a calculated_remotes entry is neither an int nor a string (the Go dynamic type is reported via %T). Config values of unsupported types such as bool, float, lists, or nested maps cannot be interpreted as a port.","triggerScenarios":"Setting port in a calculated_remotes entry to a non-scalar type, e.g. port: true, port: 4242.5 (parsed as float), or a list/map value in the YAML.","commonSituations":"YAML misconfiguration where the port line is accidentally structured (extra indentation making it a map), boolean-ish values like yes/no, or float-looking numbers.","solutions":["Set port as a plain integer: port: 4242","Quote the value to force string type if your YAML tooling mangles it: port: \"4242\"","Check indentation so the port value is a scalar, not a nested structure"],"exampleFix":"// before\ncalculated_remotes:\n  - mask: 10.0.0.0/8\n    port:\n      main: 4242\n// after\ncalculated_remotes:\n  - mask: 10.0.0.0/8\n    port: 4242","handlingStrategy":"type-guard","validationCode":"func isScalarPort(v any) bool {\n    switch t := v.(type) {\n    case int:\n        return t > 0 && t <= 65535\n    case string:\n        return validPortString(t)\n    default:\n        return false\n    }\n}","typeGuard":"func isIntLike(raw any) bool {\n    switch raw.(type) {\n    case int, string:\n        return true\n    default:\n        return false\n    }\n}","tryCatchPattern":"if err != nil {\n    if strings.Contains(err.Error(), \"invalid port (type\") {\n        log.Fatalf(\"calculated_remotes port has unsupported YAML type: %v\", err)\n    }\n    return err\n}","preventionTips":["Ensure the port value is a YAML scalar; watch indentation that creates maps","Avoid YAML booleans (yes/no/on) and floats as port values","Validate types with a config schema (e.g. JSON Schema over the YAML) before load"],"tags":["config","yaml","type-error","port"],"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"}