{"record":{"id":"5a533727ff1ca11d","repo":"owasp-amass/amass","slug":"failed-to-acquire-the-entity-with-id-s","errorCode":null,"errorMessage":"failed to acquire the entity with ID: %s","messagePattern":"failed to acquire the entity with ID: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/plugins/horizontals/ipaddr.go","lineNumber":66,"sourceCode":"}\n\nfunc (h *horaddr) lookupPTRRecordName(sess et.Session, ip *dbt.Entity) (*dbt.Entity, error) {\n\tsince, err := support.TTLStartTime(sess.Config(), string(oam.IPAddress), string(oam.FQDN), h.plugin.name)\n\tif err != nil || since.IsZero() {\n\t\treturn nil, errors.New(\"IPAddress -> FQDN transformation not supported\")\n\t}\n\n\tctx, cancel := context.WithTimeout(sess.Ctx(), 30*time.Second)\n\tdefer cancel()\n\n\tedges, err := sess.DB().OutgoingEdges(ctx, ip, since, \"ptr_record\")\n\tif err != nil || len(edges) == 0 {\n\t\treturn nil, fmt.Errorf(\"no PTR records found for %s\", ip.Asset.Key())\n\t}\n\n\tptr, err := sess.DB().FindEntityById(ctx, edges[0].ToEntity.ID)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to acquire the entity with ID: %s\", edges[0].ToEntity.ID)\n\t}\n\n\treturn ptr, nil\n}\n\nfunc (h *horaddr) lookupPTRRecordData(sess et.Session, ptr *dbt.Entity) (*dbt.Entity, error) {\n\tsince, err := support.TTLStartTime(sess.Config(), string(oam.FQDN), string(oam.FQDN), h.plugin.name)\n\tif err != nil || since.IsZero() {\n\t\treturn nil, errors.New(\"FQDN -> FQDN transformation not supported\")\n\t}\n\n\tctx, cancel := context.WithTimeout(sess.Ctx(), 30*time.Second)\n\tdefer cancel()\n\n\tedges, err := sess.DB().OutgoingEdges(ctx, ptr, since, \"dns_record\")\n\tif err != nil || len(edges) == 0 {\n\t\treturn nil, fmt.Errorf(\"no PTR data found for %s\", ptr.Asset.Key())\n\t}","sourceCodeStart":48,"sourceCodeEnd":84,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/engine/plugins/horizontals/ipaddr.go#L48-L84","documentation":"After finding a PTR edge, lookupPTRRecordName resolves the edge's destination entity by ID via sess.DB().FindEntityById. If that lookup fails, the referenced PTR name entity is missing from the graph (dangling edge) or the store errored, so the function returns this error with the entity ID. It indicates graph inconsistency or a storage-layer failure.","triggerScenarios":"sess.DB().FindEntityById(ctx, edges[0].ToEntity.ID) returns an error — the entity ID referenced by the ptr_record edge no longer exists (deleted/released data), the ID is invalid, or the graph store returned an internal error.","commonSituations":"Data release/garbage collection removed the FQDN entity while edges remained; graph DB corrupted or partially migrated; concurrent scan deleting entities mid-lookup; storage backend (e.g., in-memory vs persistent) mismatch.","solutions":["Re-run the discovery so the PTR edge and its entity are recreated consistently.","Inspect the graph store for the entity ID to determine whether it was deleted or never stored.","Check whether data release/pruning ran between edge creation and this lookup and adjust the 'since' window accordingly.","Log the underlying FindEntityById error to distinguish not-found from a storage failure.","Iterate over all ptr edges (not just edges[0]) so one dangling edge does not fail the whole lookup."],"exampleFix":"// before\nptr, err := sess.DB().FindEntityById(ctx, edges[0].ToEntity.ID)\nif err != nil {\n\treturn nil, fmt.Errorf(\"failed to acquire the entity with ID: %s\", edges[0].ToEntity.ID)\n}\n// after\nvar ptr *dbt.Entity\nfor _, edge := range edges {\n\tif p, err := sess.DB().FindEntityById(ctx, edge.ToEntity.ID); err == nil {\n\t\tptr = p\n\t\tbreak\n\t}\n}\nif ptr == nil {\n\treturn nil, fmt.Errorf(\"failed to acquire PTR entity for %s: %w\", ip.Asset.Key(), err)\n}","handlingStrategy":"retry","validationCode":"if edges[0].ToEntity == nil || edges[0].ToEntity.ID == \"\" {\n\treturn fmt.Errorf(\"ptr edge has no target entity\")\n}","typeGuard":null,"tryCatchPattern":"ptr, err := sess.DB().FindEntityById(ctx, edge.ToEntity.ID)\nif err != nil {\n\t// try next edge or re-run discovery to rebuild the entity\n\tcontinue\n}","preventionTips":["Avoid data-release pruning between edge creation and lookup","Iterate all edges instead of only edges[0]","Re-run discovery when dangling edges are detected","Log the underlying FindEntityById error cause"],"tags":["go","database","entity","graph"],"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-14T05:17:10.506Z"}