{"record":{"id":"ce82aa1ae91ff87c","repo":"owasp-amass/amass","slug":"failed-to-obtain-the-entity-for-identifier-s-s-ce82aa","errorCode":null,"errorMessage":"failed to obtain the entity for Identifier - %s:%s","messagePattern":"failed to obtain the entity for Identifier - (.+?):(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"engine/plugins/support/org/gleif.go","lineNumber":58,"sourceCode":"\t}\n\n\tif err := createRelation(ctx, sess, orgent, &oamgen.SimpleRelation{Name: \"id\"}, ident, src); err != nil {\n\t\treturn nil, err\n\t}\n\n\treturn ident, nil\n}\n\nfunc FindOrgByLEICode(sess et.Session, lei string, src *et.Source) (*dbt.Entity, error) {\n\tctx, cancel := context.WithTimeout(sess.Ctx(), 30*time.Second)\n\tdefer cancel()\n\n\tids, err := sess.DB().FindEntitiesByContent(ctx, oam.Identifier, time.Time{}, 1, dbt.ContentFilters{\n\t\t\"id\":      lei,\n\t\t\"id_type\": oamgen.LEICode,\n\t})\n\tif err != nil || len(ids) != 1 {\n\t\treturn nil, fmt.Errorf(\"failed to obtain the entity for Identifier - %s:%s\", oamgen.LEICode, lei)\n\t}\n\tident := ids[0]\n\n\tif edges, err := sess.DB().IncomingEdges(ctx, ident, time.Time{}, \"id\"); err == nil && len(edges) > 0 {\n\t\tfor _, edge := range edges {\n\t\t\tif tags, err := sess.DB().FindEdgeTags(ctx, edge, time.Time{}, src.Name); err != nil || len(tags) == 0 {\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif o, err := sess.DB().FindEntityById(ctx, edge.FromEntity.ID); err == nil && o != nil {\n\t\t\t\tif _, valid := o.Asset.(*oamorg.Organization); valid {\n\t\t\t\t\treturn o, nil\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn nil, fmt.Errorf(\"failed to obtain the Organization associated with Identifier - %s:%s\", oamgen.LEICode, lei)\n}","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/engine/plugins/support/org/gleif.go#L40-L76","documentation":"FindOrgByLEICode looks up an Organization via its LEI Identifier entity (id_type=LEICode). If FindEntitiesByContent fails or does not return exactly one LEI identifier, this error is returned; LEI lookups are expected to be unique, so a non-single match is treated as inconclusive.","triggerScenarios":"Called by store and getOrganization in the GLEIF plugin for an org's LEI; the graph has no LEI Identifier for that code, the query errors, or (unexpectedly) multiple LEI identifiers share the code.","commonSituations":"LEI never ingested before (expected cache miss in the GLEIF enrichment flow); asset DB unavailable; malformed/non-canonical LEI string (wrong length/checksum characters) not matching the stored claim; duplicate identifiers from concurrent ingestion.","solutions":["Treat as a cache miss: the GLEIF plugin fetches org details from the GLEIF API and calls CreateOrgAsset to create the org and LEI claim.","Verify the LEI is the canonical 20-character form before lookup.","Check asset DB health if the query errored rather than returned zero rows.","Deduplicate if multiple LEI identifiers exist for the same code."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"func isValidLEI(lei string) bool {\n    return len(lei) == 20\n}\n// only query with a canonical LEI\nif !isValidLEI(lei) { return nil, errors.New(\"invalid LEI\") }","typeGuard":"func isValidLEI(lei string) bool { return len(lei) == 20 }","tryCatchPattern":"if orgent, err := org.FindOrgByLEICode(sess, lei, src); err != nil {\n    // cache miss: fetch from GLEIF API and CreateOrgAsset to persist org + LEI claim\n    orgent, err = org.CreateOrgAsset(sess, nil, nil, fetchedOrg, src)\n}","preventionTips":["Treat missing LEI claims as expected cache misses in the GLEIF flow.","Normalize LEIs to the canonical 20-character form before lookup.","Ensure asset DB availability before enrichment.","Prevent duplicate LEI identifiers from concurrent ingestion with locking (as CreateOrgAsset does)."],"tags":["database","graph-lookup","lei","not-found","amass"],"backgroundTag":"entity-not-found","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"}