owasp-amass/amass · error

unsupported port type: %T

Error message

unsupported port type: %T

What it means

parsePorts switches on the dynamic type of each port entry and only supports string and int. Any other type (float64 from JSON, nested list, bool, etc.) hits the default case and returns this error naming the Go type via %T.

Source

Thrown at config/scope.go:123

			s.Ports = append(s.Ports, p)
		case string: // If it's a string, check if it's a range or a single port
			if strings.Contains(p, "-") {
				// Handle port range
				portRange, err := convertPortRangeToSlice(p)
				if err != nil {
					return err
				}
				s.Ports = append(s.Ports, portRange...)
			} else {
				// Handle single port string
				portNum, err := strconv.Atoi(p)
				if err != nil {
					return fmt.Errorf("invalid port string: %v", err)
				}
				s.Ports = append(s.Ports, portNum)
			}
		default:
			return fmt.Errorf("unsupported port type: %T", p)
		}
	}

	return nil
}

func convertPortRangeToSlice(portRange string) ([]int, error) {
	var ports []int

	parts := strings.Split(portRange, "-")
	if len(parts) != 2 {
		return nil, fmt.Errorf("invalid port range format")
	}

	start, err := strconv.Atoi(parts[0])
	if err != nil {
		return nil, fmt.Errorf("invalid start port: %v", err)
	}

View on GitHub (pinned to 79299dce87)

Solutions

  1. Write port values as integers (80) not decimals (80.0) in the config file
  2. Flatten nested lists so each entry is a scalar string or int
  3. When building options in Go, use int or string element types inside the interface{} slice

Example fix

// before (yaml)
ports: [80.0, [443]]
// after (yaml)
ports: [80, 443]
Defensive patterns

Strategy: type-guard

Validate before calling

for _, p := range ports { switch p.(type) { case string, int: default: return fmt.Errorf("port entry must be string or int, got %T", p) } }

Type guard

func isSupportedPortType(v interface{}) bool { switch v.(type) { case string, int: return true }; return false }

Prevention

When it happens

Trigger: A Ports entry in the scope settings is a type other than string or int — commonly float64 when the config was decoded from JSON/YAML (numbers unmarshal as float64 into interface{}), or a nested slice.

Common situations: YAML/JSON config with ports written as 80.0 or a nested list; programmatic config passing []string instead of []interface{} of strings/ints.

Related errors


AI-assisted analysis of owasp-amass/amass@79299dce87 (2026-09-06). Data as JSON: /api/errors/4d955a297ad03575. Report an issue: GitHub.