owasp-amass/amass · error

failed to acquire the entity with ID: %s

Error message

failed to acquire the entity with ID: %s

What it means

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.

Source

Thrown at engine/plugins/horizontals/ipaddr.go:66

}

func (h *horaddr) lookupPTRRecordName(sess et.Session, ip *dbt.Entity) (*dbt.Entity, error) {
	since, err := support.TTLStartTime(sess.Config(), string(oam.IPAddress), string(oam.FQDN), h.plugin.name)
	if err != nil || since.IsZero() {
		return nil, errors.New("IPAddress -> FQDN transformation not supported")
	}

	ctx, cancel := context.WithTimeout(sess.Ctx(), 30*time.Second)
	defer cancel()

	edges, err := sess.DB().OutgoingEdges(ctx, ip, since, "ptr_record")
	if err != nil || len(edges) == 0 {
		return nil, fmt.Errorf("no PTR records found for %s", ip.Asset.Key())
	}

	ptr, err := sess.DB().FindEntityById(ctx, edges[0].ToEntity.ID)
	if err != nil {
		return nil, fmt.Errorf("failed to acquire the entity with ID: %s", edges[0].ToEntity.ID)
	}

	return ptr, nil
}

func (h *horaddr) lookupPTRRecordData(sess et.Session, ptr *dbt.Entity) (*dbt.Entity, error) {
	since, err := support.TTLStartTime(sess.Config(), string(oam.FQDN), string(oam.FQDN), h.plugin.name)
	if err != nil || since.IsZero() {
		return nil, errors.New("FQDN -> FQDN transformation not supported")
	}

	ctx, cancel := context.WithTimeout(sess.Ctx(), 30*time.Second)
	defer cancel()

	edges, err := sess.DB().OutgoingEdges(ctx, ptr, since, "dns_record")
	if err != nil || len(edges) == 0 {
		return nil, fmt.Errorf("no PTR data found for %s", ptr.Asset.Key())
	}

View on GitHub (pinned to 79299dce87)

Solutions

  1. Re-run the discovery so the PTR edge and its entity are recreated consistently.
  2. Inspect the graph store for the entity ID to determine whether it was deleted or never stored.
  3. Check whether data release/pruning ran between edge creation and this lookup and adjust the 'since' window accordingly.
  4. Log the underlying FindEntityById error to distinguish not-found from a storage failure.
  5. Iterate over all ptr edges (not just edges[0]) so one dangling edge does not fail the whole lookup.

Example fix

// before
ptr, err := sess.DB().FindEntityById(ctx, edges[0].ToEntity.ID)
if err != nil {
	return nil, fmt.Errorf("failed to acquire the entity with ID: %s", edges[0].ToEntity.ID)
}
// after
var ptr *dbt.Entity
for _, edge := range edges {
	if p, err := sess.DB().FindEntityById(ctx, edge.ToEntity.ID); err == nil {
		ptr = p
		break
	}
}
if ptr == nil {
	return nil, fmt.Errorf("failed to acquire PTR entity for %s: %w", ip.Asset.Key(), err)
}
Defensive patterns

Strategy: retry

Validate before calling

if edges[0].ToEntity == nil || edges[0].ToEntity.ID == "" {
	return fmt.Errorf("ptr edge has no target entity")
}

Try / catch

ptr, err := sess.DB().FindEntityById(ctx, edge.ToEntity.ID)
if err != nil {
	// try next edge or re-run discovery to rebuild the entity
	continue
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of owasp-amass/amass@79299dce87 (2026-09-06). Data as JSON: /api/errors/5a533727ff1ca11d. Report an issue: GitHub.