{"record":{"id":"fe23d9988d13a306","repo":"owasp-amass/amass","slug":"failed-to-obtain-the-registered-cidr-netblock-for","errorCode":null,"errorMessage":"failed to obtain the registered CIDR Netblock for: %s","messagePattern":"failed to obtain the registered CIDR Netblock for: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/plugins/horizontals/plugin.go","lineNumber":511,"sourceCode":"\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())\n}\n","sourceCodeStart":493,"sourceCodeEnd":513,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/engine/plugins/horizontals/plugin.go#L493-L513","documentation":"getRegisteredNetblockEntity looks up the netblock entity in the graph by filtering entities of type oam.Netblock on content cidr == iprec.CIDR.String(). If the query does not return exactly one match, the registered netblock entity cannot be linked and this error is returned. It is the netblock counterpart of the registered-domain lookup and guards scope relationship creation.","triggerScenarios":"sess.DB().FindEntitiesByContent(ctx, oam.Netblock, time.Time{}, 1, {\"cidr\": iprec.CIDR.String()}) errors, returns 0 entities (netblock never discovered/stored), or returns multiple entities matching that CIDR string, when called from processInScope/processIPNetRecord.","commonSituations":"Processing an IP whose netblock record has not yet been stored (discovery ordering); CIDR string format mismatch (e.g., /32 vs single IP normalization) between records; duplicate netblock entities from multiple data sources; DB query failure.","solutions":["Ensure netblock entities are inserted before IP records referencing them, or create the netblock entity on demand here.","Verify the CIDR string representation is identical at insert and query time (use ipnet.CIDR.String() consistently).","Deduplicate netblock entities so exactly one exists per CIDR.","Log the underlying FindEntitiesByContent error to separate storage failure from genuinely missing data.","Fall back to len(ents) >= 1 taking the first entity if duplicates are acceptable."],"exampleFix":"// before\nif ents, err := sess.DB().FindEntitiesByContent(ctx, oam.Netblock, time.Time{}, 1, dbt.ContentFilters{\"cidr\": iprec.CIDR.String()}); err == nil && len(ents) == 1 {\n\treturn ents[0], nil\n}\nreturn nil, fmt.Errorf(\"failed to obtain the registered CIDR Netblock for: %s\", iprec.CIDR.String())\n// after\nents, err := sess.DB().FindEntitiesByContent(ctx, oam.Netblock, time.Time{}, 1, dbt.ContentFilters{\"cidr\": iprec.CIDR.String()})\nif err != nil {\n\treturn nil, fmt.Errorf(\"failed to obtain the registered CIDR Netblock for: %s: %w\", iprec.CIDR.String(), err)\n}\nif len(ents) == 0 {\n\treturn nil, fmt.Errorf(\"registered CIDR netblock entity not found for: %s\", iprec.CIDR.String())\n}\nreturn ents[0], nil","handlingStrategy":"fallback","validationCode":"if iprec.CIDR == nil || iprec.CIDR.String() == \"\" {\n\treturn fmt.Errorf(\"missing CIDR on netblock record\")\n}","typeGuard":"iprec, ok := record.Asset.(*oamreg.IPNetRecord)\nif !ok {\n\t// not an IP net record\n}","tryCatchPattern":"netEnt, err := getRegisteredNetblockEntity(sess, record)\nif err != nil {\n\t// log and continue; scope link is optional\n\treturn nil\n}","preventionTips":["Use a canonical CIDR string format at insert and query time","Store netblocks before IP records referencing them","Deduplicate netblock entities per CIDR","Create the netblock entity on demand when missing"],"tags":["go","database","netblock","cidr"],"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"}