{"record":{"id":"a9221528403b2697","repo":"owasp-amass/amass","slug":"failed-to-obtain-the-registered-domain-name-fqdn-f","errorCode":null,"errorMessage":"failed to obtain the registered domain name FQDN for: %s","messagePattern":"failed to obtain the registered domain name FQDN for: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/plugins/horizontals/plugin.go","lineNumber":493,"sourceCode":"\t}\n}\n\nfunc (h *horizPlugin) getRegisteredDomainEntity(sess et.Session, record *dbt.Entity) (*dbt.Entity, error) {\n\tdr, valid := record.Asset.(*oamreg.DomainRecord)\n\tif !valid {\n\t\treturn nil, errors.New(\"failed to cast the DomainRecord\")\n\t}\n\n\tctx, cancel := context.WithTimeout(sess.Ctx(), 30*time.Second)\n\tdefer cancel()\n\n\tif ents, err := sess.DB().FindEntitiesByContent(ctx, oam.FQDN, time.Time{}, 1, dbt.ContentFilters{\n\t\t\"name\": dr.Domain,\n\t}); err == nil && len(ents) == 1 {\n\t\treturn ents[0], nil\n\t}\n\n\treturn nil, fmt.Errorf(\"failed to obtain the registered domain name FQDN for: %s\", dr.Domain)\n}\n\nfunc (h *horizPlugin) getRegisteredNetblockEntity(sess et.Session, record *dbt.Entity) (*dbt.Entity, error) {\n\tiprec, valid := record.Asset.(*oamreg.IPNetRecord)\n\tif !valid {\n\t\treturn nil, errors.New(\"failed to cast the IPNetRecord\")\n\t}\n\n\tctx, cancel := context.WithTimeout(sess.Ctx(), 30*time.Second)\n\tdefer cancel()\n\n\tif ents, err := sess.DB().FindEntitiesByContent(ctx, oam.Netblock, time.Time{}, 1, dbt.ContentFilters{\n\t\t\"cidr\": iprec.CIDR.String(),\n\t}); err == nil && len(ents) == 1 {\n\t\treturn ents[0], nil\n\t}\n\n\treturn nil, fmt.Errorf(\"failed to obtain the registered CIDR Netblock for: %s\", iprec.CIDR.String())","sourceCodeStart":475,"sourceCodeEnd":511,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/engine/plugins/horizontals/plugin.go#L475-L511","documentation":"getRegisteredDomainEntity looks up the registered-domain FQDN entity in the graph by filtering entities of type oam.FQDN on content name == dr.Domain. If exactly one match is not found (query error, zero matches, or multiple matches), the registered domain entity cannot be associated and this error is returned. It ensures scope relationships are only created against a canonical registered-domain entity.","triggerScenarios":"sess.DB().FindEntitiesByContent(ctx, oam.FQDN, time.Time{}, 1, {\"name\": dr.Domain}) errors, returns 0 entities (domain record never discovered/stored), or returns >1 entities (len(ents) != 1) for the domain discovered via processDomainRecord/processInScope.","commonSituations":"Processing a subdomain whose apex domain has not yet been added to the graph (ordering issue); the apex was discovered but stored with different casing; multiple FQDN entities share the name due to re-discovery; DB query failure.","solutions":["Ensure the apex/registered domain is discovered and stored before processing its subdomains, or create the entity on demand here.","Normalize name casing/format before the content filter to avoid duplicate/mismatched entities.","Deduplicate FQDN entities in the graph so exactly one entity exists per registered domain.","Check the DB error from FindEntitiesByContent — a storage failure surfaces here as len(ents)==0 via err == nil being false.","Relax the len(ents) == 1 requirement to len(ents) >= 1 and take the first match if duplicates are tolerated."],"exampleFix":"// before\nif ents, err := sess.DB().FindEntitiesByContent(ctx, oam.FQDN, time.Time{}, 1, dbt.ContentFilters{\"name\": dr.Domain}); err == nil && len(ents) == 1 {\n\treturn ents[0], nil\n}\nreturn nil, fmt.Errorf(\"failed to obtain the registered domain name FQDN for: %s\", dr.Domain)\n// after\nents, err := sess.DB().FindEntitiesByContent(ctx, oam.FQDN, time.Time{}, 1, dbt.ContentFilters{\"name\": dr.Domain})\nif err != nil {\n\treturn nil, fmt.Errorf(\"failed to obtain the registered domain name FQDN for: %s: %w\", dr.Domain, err)\n}\nif len(ents) == 0 {\n\treturn nil, fmt.Errorf(\"registered domain FQDN entity not found for: %s\", dr.Domain)\n}\nreturn ents[0], nil","handlingStrategy":"fallback","validationCode":"// ensure apex exists before processing subdomains\nents, _ := sess.DB().FindEntitiesByContent(ctx, oam.FQDN, time.Time{}, 1, dbt.ContentFilters{\"name\": dr.Domain})\nif len(ents) == 0 {\n\t// create or discover the apex entity first\n}","typeGuard":null,"tryCatchPattern":"domEnt, err := getRegisteredDomainEntity(sess, dr)\nif err != nil {\n\t// log and continue; scope link is optional\n\treturn nil\n}","preventionTips":["Discover/store apex domains before subdomain processing","Normalize FQDN casing before content-filter lookups","Deduplicate FQDN entities in the graph","Create the apex entity on demand when missing"],"tags":["go","database","domains","scope"],"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-14T00:17:10.932Z"}