{"record":{"id":"42cdcd0f29f566f8","repo":"owasp-amass/amass","slug":"failed-to-discover-or-create-the-organization-asse","errorCode":null,"errorMessage":"failed to discover or create the Organization asset","messagePattern":"failed to discover or create the Organization asset","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/plugins/support/org/org.go","lineNumber":108,"sourceCode":"\t\t// identify this caller as a source of the Organization asset\n\t\t_, _ = sess.DB().CreateEntityProperty(ctx, orgent, &oamgen.SourceProperty{\n\t\t\tSource:     src.Name,\n\t\t\tConfidence: src.Confidence,\n\t\t})\n\n\t\tif obj != nil && rel != nil && obj.ID != orgent.ID {\n\t\t\tctx, cancel := context.WithTimeout(sess.Ctx(), 10*time.Second)\n\t\t\tdefer cancel()\n\n\t\t\tif err := createRelation(ctx, sess, obj, rel, orgent, src); err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t}\n\n\t\treturn orgent, nil\n\t}\n\n\treturn nil, errors.New(\"failed to discover or create the Organization asset\")\n}\n\nfunc genNormName(o *oamorg.Organization) string {\n\tname := o.Name\n\n\tif o.LegalName != \"\" {\n\t\tname = o.LegalName\n\t}\n\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 {","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/engine/plugins/support/org/org.go#L90-L126","documentation":"This is the terminal fallback in CreateOrgAsset: after all lookup paths (name claim, legal-name claim, legal-name edge, ancestor checks) fail to produce an existing orgent, and the creation branch also left orgent nil, the function returns this generic error indicating it could neither discover nor create the Organization asset.","triggerScenarios":"Reached when orgent remains nil at the end of CreateOrgAsset — typically the result of an earlier silently-ignored lookup error or the failed CreateAsset path leaving orgent nil despite no error propagating directly.","commonSituations":"Compound failures: lookup errors were swallowed (e.g. FindOrgByLegalNameClaim's error is discarded with _) and creation also failed; inconsistent DB state; all dedup branches exhausted without a match or successful create.","solutions":["Enable debug logging around CreateOrgAsset to see which lookup/creation branch failed","Check DB connectivity — this generic message usually masks a CreateAsset failure from [47]","Re-run the operation after fixing the underlying DB issue; the state machine has no retry loop","Audit callers for swallowed errors (e.g. `orgent, _ = FindOrgByLegalNameClaim(...)`) and log them instead"],"exampleFix":"// before\norgent, _ = FindOrgByLegalNameClaim(sess, o.LegalName, src)\n\n// after\norgent, err = FindOrgByLegalNameClaim(sess, o.LegalName, src)\nif err != nil {\n    return nil, fmt.Errorf(\"legal-name lookup failed: %w\", err)\n}","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"orgent, err := CreateOrgAsset(sess, obj, rel, org, src)\nif err != nil {\n    log.Printf(\"discover-or-create failed: %v\", err)\n    // inspect DB state, then retry once\n}","preventionTips":["Fix underlying DB issues first — this error masks earlier failures","Avoid swallowing lookup errors (orgent, _ = ...) so root causes surface","Retry after transient DB failures; verify state between attempts"],"tags":["go","fallback","organization","create-failed"],"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"}