sundowndev/phoneinfoga · warning

search engine ID and/or API key is not defined

Error message

search engine ID and/or API key is not defined

What it means

The Google Custom Search scanner's DryRun checks that both GOOGLECSE_CX (search engine ID) and GOOGLE_API_KEY are set in the environment; if either is empty it returns 'search engine ID and/or API key is not defined' and the scanner is skipped.

Source

Thrown at lib/remote/googlecse_scanner.go:68

	}

	return &googleCSEScanner{
		MaxResults: int64(maxResults),
		httpClient: HTTPclient,
	}
}

func (s *googleCSEScanner) Name() string {
	return GoogleCSE
}

func (s *googleCSEScanner) Description() string {
	return "Googlecse searches for footprints of a given phone number on the web using Google Custom Search Engine."
}

func (s *googleCSEScanner) DryRun(_ number.Number, opts ScannerOptions) error {
	if opts.GetStringEnv("GOOGLECSE_CX") == "" || opts.GetStringEnv("GOOGLE_API_KEY") == "" {
		return errors.New("search engine ID and/or API key is not defined")
	}
	return nil
}

func (s *googleCSEScanner) Run(n number.Number, opts ScannerOptions) (interface{}, error) {
	var allItems []*customsearch.Result
	var dorks []*GoogleSearchDork
	var totalResultCount int
	var totalRequestCount int
	var cx = opts.GetStringEnv("GOOGLECSE_CX")
	var apikey = opts.GetStringEnv("GOOGLE_API_KEY")

	dorks = append(dorks, s.generateDorkQueries(n)...)

	customsearchService, err := customsearch.NewService(
		context.Background(),
		option.WithAPIKey(apikey),
		option.WithHTTPClient(s.httpClient),

View on GitHub (pinned to 55807b05b7)

Solutions

  1. Export both GOOGLECSE_CX and GOOGLE_API_KEY before running the scan (e.g. in .env or shell profile)
  2. Verify with `echo $GOOGLECSE_CX $GOOGLE_API_KEY` that both are non-empty in the same shell/session that runs the tool
  3. If you do not want this scanner, disable it explicitly instead of relying on missing creds

Example fix

// before
scan --number +14155552671   # GOOGLE_API_KEY unset
// after
export GOOGLECSE_CX=017576662512468239146:omuauf_lfve
export GOOGLE_API_KEY=AIzaSy...
scan --number +14155552671
Defensive patterns

Strategy: validation

Validate before calling

for v in GOOGLECSE_CX GOOGLE_API_KEY; do
  [ -n "${!v}" ] || echo "missing $v" >&2
done
// Go equivalent:
if os.Getenv("GOOGLECSE_CX") == "" || os.Getenv("GOOGLE_API_KEY") == "" {
    return errors.New("googlecse scanner requires GOOGLECSE_CX and GOOGLE_API_KEY")
}

Prevention

When it happens

Trigger: Running a scan that includes the googlecse scanner when either GOOGLECSE_CX or GOOGLE_API_KEY is unset or an empty string in the environment passed via ScannerOptions.GetStringEnv.

Common situations: Credentials file not sourced in the shell, running inside Docker/systemd/CI where env vars were not forwarded, typo in variable name, or having an API key but never creating a Google Custom Search Engine (so no CX ID).

Understand the failure class

Background: "environment variable is not set" and "Missing keys in environment" errors: what missing required env var messages mean and how to fix them — this error's family across 28 libraries.

Related errors


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