slackhq/nebula · error
invalid port (type %T): %v
Error message
invalid port (type %T): %v
What it means
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.
Source
Thrown at calculated_remote.go:159
if err != nil {
return nil, fmt.Errorf("invalid mask: %s", rawMask)
}
var port int
rawValue = rawMap["port"]
if rawValue == nil {
return nil, fmt.Errorf("missing port: %v", rawMap)
}
switch v := rawValue.(type) {
case int:
port = v
case string:
port, err = strconv.Atoi(v)
if err != nil {
return nil, fmt.Errorf("invalid port: %s: %w", v, err)
}
default:
return nil, fmt.Errorf("invalid port (type %T): %v", rawValue, rawValue)
}
return newCalculatedRemote(cidr, maskCidr, port)
}
View on GitHub (pinned to dd8f660c0a)
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
Example fix
// before
calculated_remotes:
- mask: 10.0.0.0/8
port:
main: 4242
// after
calculated_remotes:
- mask: 10.0.0.0/8
port: 4242 Defensive patterns
Strategy: type-guard
Validate before calling
func isScalarPort(v any) bool {
switch t := v.(type) {
case int:
return t > 0 && t <= 65535
case string:
return validPortString(t)
default:
return false
}
} Type guard
func isIntLike(raw any) bool {
switch raw.(type) {
case int, string:
return true
default:
return false
}
} Try / catch
if err != nil {
if strings.Contains(err.Error(), "invalid port (type") {
log.Fatalf("calculated_remotes port has unsupported YAML type: %v", err)
}
return err
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- config `%s` has invalid type: %T
- calculated_remotes entry has invalid type: %T
- invalid type: %T
- invalid mask (type %T): %v
- missing port: %v
AI-assisted analysis of slackhq/nebula@dd8f660c0a (2026-09-03).
Data as JSON: /api/errors/888a5aa2c022b289.
Report an issue: GitHub.