{"record":{"id":"d8788c4c6a0a86d6","repo":"owasp-amass/amass","slug":"gleifsearchfuzzycompletions-s","errorCode":null,"errorMessage":"GLEIFSearchFuzzyCompletions: %s","messagePattern":"GLEIFSearchFuzzyCompletions: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/plugins/api/gleif/gleif.go","lineNumber":41,"sourceCode":"\nfunc init() {\n\tlimit := rate.Every(3 * time.Second)\n\n\tgleifLimit = rate.NewLimiter(limit, 1)\n}\n\n// GLEIFSearchFuzzyCompletions performs the fuzzy completion search for the given name.\nfunc GLEIFSearchFuzzyCompletions(ctx context.Context, name string) (*FuzzyCompletionsResponse, error) {\n\tu := \"https://api.gleif.org/api/v1/fuzzycompletions?field=entity.legalName&q=\" + url.QueryEscape(name)\n\n\t_ = gleifLimit.Wait(ctx)\n\twctx, cancel := context.WithTimeout(ctx, 60*time.Second)\n\tdefer cancel()\n\n\tresp, err := amasshttp.RequestWebPage(wctx, amasshttp.DefaultClient, &amasshttp.Request{URL: u})\n\tif err != nil || resp.Body == \"\" {\n\t\tmsg := fmt.Sprintf(\"Failed to obtain the LEI record for %s: %s\", name, err)\n\t\treturn nil, fmt.Errorf(\"GLEIFSearchFuzzyCompletions: %s\", msg)\n\t}\n\n\tvar result FuzzyCompletionsResponse\n\tif err := json.Unmarshal([]byte(resp.Body), &result); err != nil {\n\t\tmsg := fmt.Sprintf(\"Failed to unmarshal the LEI record for %s: %s\", name, err)\n\t\treturn nil, fmt.Errorf(\"GLEIFSearchFuzzyCompletions: %s\", msg)\n\t} else if len(result.Data) == 0 {\n\t\treturn nil, fmt.Errorf(\"GLEIFSearchFuzzyCompletions: no results found\")\n\t}\n\n\treturn &result, nil\n}\n\n// GLEIFGetLEIRecord retrieves the LEI record for the given identifier.\nfunc GLEIFGetLEIRecord(ctx context.Context, id string) (*LEIRecord, error) {\n\tu := \"https://api.gleif.org/api/v1/lei-records/\" + id\n\n\t_ = gleifLimit.Wait(ctx)","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/engine/plugins/api/gleif/gleif.go#L23-L59","documentation":"GLEIFSearchFuzzyCompletions queries the GLEIF API for fuzzy-completion LEI records matching a name. It wraps any failure to fetch or read the HTTP response body into this error, preserving the underlying cause and the queried name. The plugin cannot proceed without the LEI data, so it returns a hard error instead of partial results.","triggerScenarios":"amasshttp.RequestWebPage returns a non-nil err (DNS failure, TLS error, timeout after the 60s wctx deadline, connection refused) or returns a response with an empty Body (e.g., HTTP error status with no payload) when called with the GLEIF fuzzy-completions URL for a given name.","commonSituations":"Offline or air-gapped environments; corporate proxies blocking api.gleif.org; GLEIF API rate limiting or outage returning empty bodies; transient network drops during long scans; DNS resolution failures in containers.","solutions":["Check network connectivity to https://api.gleif.org from the host running the scan (curl the URL directly).","Retry the lookup; transient network failures are common, and the request already uses a 60s timeout.","Verify proxy/firewall rules allow HTTPS egress to api.gleif.org.","Inspect the wrapped cause in msg (logged with the error) to distinguish timeout vs DNS vs empty-body and address that specific cause.","Implement a fallback to the non-fuzzy GLEIF search endpoint if fuzzy completions repeatedly fail."],"exampleFix":"// before\nresp, err := amasshttp.RequestWebPage(wctx, amasshttp.DefaultClient, &amasshttp.Request{URL: u})\nif err != nil || resp.Body == \"\" {\n\treturn nil, fmt.Errorf(\"GLEIFSearchFuzzyCompletions: %s\", msg)\n}\n// after\nresp, err := amasshttp.RequestWebPage(wctx, amasshttp.DefaultClient, &amasshttp.Request{URL: u})\nif err != nil {\n\treturn nil, fmt.Errorf(\"GLEIFSearchFuzzyCompletions: %w\", err) // caller can errors.Is/As on the cause and retry\n}\nif resp.Body == \"\" {\n\treturn nil, fmt.Errorf(\"GLEIFSearchFuzzyCompletions: empty response body\")\n}","handlingStrategy":"try-catch","validationCode":"url := \"https://api.gleif.org/api/v1/fuzzy_completions?q=\" + name\nif resp, err := http.Head(url); err != nil || resp.StatusCode != http.StatusOK {\n\t// skip GLEIF source this round\n}","typeGuard":"if resp == nil || resp.Body == \"\" {\n\treturn fmt.Errorf(\"empty GLEIF response\")\n}","tryCatchPattern":"result, err := GLEIFSearchFuzzyCompletions(ctx, name)\nif err != nil {\n\tvar netErr net.Error\n\tif errors.As(err, &netErr) && netErr.Timeout() {\n\t\t// retry with backoff\n\t} else {\n\t\t// continue without GLEIF data\n\t}\n}","preventionTips":["Verify egress to api.gleif.org before starting scans","Configure proxy settings for constrained networks","Retry transient network errors with backoff","Monitor GLEIF API status/outages"],"tags":["go","http","network","api"],"backgroundTag":"http-request-failed","analyzedSha":"79299dce87b0085db0f2f4ef3e9c52cccb49f514","analyzedAt":"2026-09-06T08:22:48.198Z","contentChangedAt":"2026-09-06T08:22:48.198Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}