sundowndev/phoneinfoga · error

given phone number is not valid

Error message

given phone number is not valid

What it means

runScan validates the user-supplied phone number with number.IsValid before doing any work; if it fails, the CLI exits immediately with 'given phone number is not valid'. The library refuses to run any scanners on input it considers unparseable or not a real phone number.

Source

Thrown at cmd/scan.go:62

			err := godotenv.Load(opts.EnvFiles...)
			if err != nil {
				logrus.WithField("error", err).Debug("Error loading .env file")
			}

			runScan(opts)
		},
	}
}

func runScan(opts *ScanCmdOptions) {
	fmt.Fprintf(color.Output, color.WhiteString("Running scan for phone number %s...\n\n"), opts.Number)

	if valid := number.IsValid(opts.Number); !valid {
		logrus.WithFields(map[string]interface{}{
			"input": opts.Number,
			"valid": valid,
		}).Debug("Input phone number is invalid")
		exitWithError(errors.New("given phone number is not valid"))
	}

	num, err := number.NewNumber(opts.Number)
	if err != nil {
		exitWithError(err)
	}

	for _, p := range opts.PluginPaths {
		err := remote.OpenPlugin(p)
		if err != nil {
			exitWithError(err)
		}
	}

	f := filter.NewEngine()
	f.AddRule(opts.DisabledScanners...)

	remoteLibrary := remote.NewLibrary(f)

View on GitHub (pinned to 55807b05b7)

Solutions

  1. Pass a full international-format number including '+' and country code, e.g. +14155552671
  2. Remove spaces, dashes, parentheses, or check which formats number.IsValid accepts in the number package
  3. Confirm the --number flag is actually populated (see the debug log field 'input' which echoes the rejected value)

Example fix

// before
scan --number 415-555-2671
// after
scan --number +14155552671
Defensive patterns

Strategy: validation

Validate before calling

import "github.com/sundowndev/phonepos/lib/number"

func validateInput(raw string) error {
    if !number.IsValid(raw) {
        return fmt.Errorf("number %q is not a valid international phone number", raw)
    }
    return nil
}
// call validateInput(opts.Number) before running the scan

Prevention

When it happens

Trigger: Running the scan command with a --number flag value that number.IsValid rejects: empty string, letters/symbols, too few digits, or a number without a valid country calling code.

Common situations: Forgetting the leading '+' and country code (e.g. '5551234' instead of '+15551234'), pasting numbers with formatting characters the parser does not accept, or an empty flag because the argument was never passed.

Related errors


AI-assisted analysis of sundowndev/phoneinfoga@55807b05b7 (2026-09-03). Data as JSON: /api/errors/4f1e31c3affdc3d2. Report an issue: GitHub.