owasp-amass/amass · error

failed to create the edge

Error message

failed to create the edge

What it means

createRelation is the shared helper for attaching edges (name claims, legal-name claims, registration IDs, LEI codes, RDAP handles) from an org entity to a subject entity. It returns this error when sess.DB().CreateEdge succeeds but returns a nil edge — meaning the database layer did not actually persist the relationship.

Source

Thrown at engine/plugins/support/org/org.go:135

	return ExtractBrandName(strings.ToLower(name))
}

func genStableOrgID(o *oamorg.Organization) string {
	id := uuid.New().String()
	return fmt.Sprintf("%s:%s", o.Name, id)
}

func createRelation(ctx context.Context, sess et.Session, obj *dbt.Entity, rel oam.Relation, subject *dbt.Entity, src *et.Source) error {
	edge, err := sess.DB().CreateEdge(ctx, &dbt.Edge{
		Relation:   rel,
		FromEntity: obj,
		ToEntity:   subject,
	})
	if err != nil {
		return err
	} else if edge == nil {
		return errors.New("failed to create the edge")
	}

	_, err = sess.DB().CreateEdgeProperty(ctx, edge, &oamgen.SourceProperty{
		Source:     src.Name,
		Confidence: src.Confidence,
	})
	return err
}

View on GitHub (pinned to 79299dce87)

Solutions

  1. Verify both obj and subject are non-nil, persisted entities with valid IDs before calling the claim APIs
  2. Check graph DB logs for the CreateEdge call to find why a nil edge was returned
  3. Confirm the session is not pointed at a read-only replica that silently drops writes
  4. Retry the claim creation — transient backend issues can produce nil edges
  5. Inspect the underlying error variable from CreateEdge, which this branch discards when err is nil

Example fix

// before
CreateOrgNameClaim(sess, orgent, name, src) // orgent never persisted

// after
savedOrg, err := CreateOrgAsset(sess, obj, rel, org, src)
if err != nil {
    return err
}
CreateOrgNameClaim(sess, savedOrg, name, src)
Defensive patterns

Strategy: validation

Validate before calling

if obj == nil || subject == nil || obj.ID == "" || subject.ID == "" {
    return fmt.Errorf("both entities must be persisted before creating edges")
}

Try / catch

if err := CreateOrgNameClaim(sess, orgent, name, src); err != nil {
    log.Printf("claim edge creation failed: %v", err)
}

Prevention

When it happens

Trigger: Any of CreateOrgNameClaim, CreateOrgLegalNameClaim, CreateOrgRegistrationIDClaim, CreateOrgLEICode, CreateOrgAsset, or CreateOrgRDAPHandle invoking createRelation where CreateEdge returns (nil, nil), or where the edge creation was attempted with invalid/missing FromEntity (obj) or ToEntity (subject).

Common situations: Graph DB accepting the request but not persisting (transaction rolled back silently); passing a nil or unsaved subject entity; DB backend quirks where nil edges signal constraint rejection; misconfigured session pointing at a read-only replica.

Related errors


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