{"record":{"id":"9f0a4133a284805a","repo":"owasp-amass/amass","slug":"failed-to-create-the-edge","errorCode":null,"errorMessage":"failed to create the edge","messagePattern":"failed to create the edge","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/plugins/support/org/org.go","lineNumber":135,"sourceCode":"\n\treturn ExtractBrandName(strings.ToLower(name))\n}\n\nfunc genStableOrgID(o *oamorg.Organization) string {\n\tid := uuid.New().String()\n\treturn fmt.Sprintf(\"%s:%s\", o.Name, id)\n}\n\nfunc createRelation(ctx context.Context, sess et.Session, obj *dbt.Entity, rel oam.Relation, subject *dbt.Entity, src *et.Source) error {\n\tedge, err := sess.DB().CreateEdge(ctx, &dbt.Edge{\n\t\tRelation:   rel,\n\t\tFromEntity: obj,\n\t\tToEntity:   subject,\n\t})\n\tif err != nil {\n\t\treturn err\n\t} else if edge == nil {\n\t\treturn errors.New(\"failed to create the edge\")\n\t}\n\n\t_, err = sess.DB().CreateEdgeProperty(ctx, edge, &oamgen.SourceProperty{\n\t\tSource:     src.Name,\n\t\tConfidence: src.Confidence,\n\t})\n\treturn err\n}\n","sourceCodeStart":117,"sourceCodeEnd":144,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/engine/plugins/support/org/org.go#L117-L144","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","solutions":["Verify both obj and subject are non-nil, persisted entities with valid IDs before calling the claim APIs","Check graph DB logs for the CreateEdge call to find why a nil edge was returned","Confirm the session is not pointed at a read-only replica that silently drops writes","Retry the claim creation — transient backend issues can produce nil edges","Inspect the underlying error variable from CreateEdge, which this branch discards when err is nil"],"exampleFix":"// before\nCreateOrgNameClaim(sess, orgent, name, src) // orgent never persisted\n\n// after\nsavedOrg, err := CreateOrgAsset(sess, obj, rel, org, src)\nif err != nil {\n    return err\n}\nCreateOrgNameClaim(sess, savedOrg, name, src)","handlingStrategy":"validation","validationCode":"if obj == nil || subject == nil || obj.ID == \"\" || subject.ID == \"\" {\n    return fmt.Errorf(\"both entities must be persisted before creating edges\")\n}","typeGuard":null,"tryCatchPattern":"if err := CreateOrgNameClaim(sess, orgent, name, src); err != nil {\n    log.Printf(\"claim edge creation failed: %v\", err)\n}","preventionTips":["Persist both endpoints (org and subject) before creating claim edges","Confirm the session targets a writable primary, not a read-only replica","Watch for CreateEdge returning nil with no error; treat as a write failure","Retry claim creation on transient DB errors"],"tags":["go","graph-edge","database","claim"],"backgroundTag":"database-write-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"}