{"record":{"id":"079432de003dfbad","repo":"owasp-amass/amass","slug":"failed-to-extract-the-ipaddress-asset","errorCode":null,"errorMessage":"failed to extract the IPAddress asset","messagePattern":"failed to extract the IPAddress asset","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/plugins/ip_netblock.go","lineNumber":73,"sourceCode":"\t\tEventType:    oam.IPAddress,\n\t\tCallback:     d.lookup,\n\t}); err != nil {\n\t\td.log.Error(fmt.Sprintf(\"Failed to register a handler: %v\", err), \"handler\", name)\n\t\treturn err\n\t}\n\n\td.log.Info(\"Plugin started\")\n\treturn nil\n}\n\nfunc (d *ipNetblock) Stop() {\n\td.log.Info(\"Plugin stopped\")\n}\n\nfunc (d *ipNetblock) lookup(e *et.Event) error {\n\tip, ok := e.Entity.Asset.(*oamnet.IPAddress)\n\tif !ok {\n\t\treturn errors.New(\"failed to extract the IPAddress asset\")\n\t}\n\n\tif reserved, cidr := amassnet.IsReservedAddress(ip.Address.String()); reserved {\n\t\tprefix, err := netip.ParsePrefix(cidr)\n\t\tif err != nil {\n\t\t\treturn nil\n\t\t}\n\n\t\tnetblock := &oamnet.Netblock{\n\t\t\tType: \"IPv4\",\n\t\t\tCIDR: prefix,\n\t\t}\n\t\tif prefix.Addr().Is6() {\n\t\t\tnetblock.Type = \"IPv6\"\n\t\t}\n\n\t\td.reservedAS(e, netblock)\n\t\treturn nil","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/engine/plugins/ip_netblock.go#L55-L91","documentation":"The ip/netblock plugin's lookup() asserts e.Entity.Asset to *oamnet.IPAddress to process IP-based events. If the asset is any other type the assertion fails and this error is returned. The plugin's event subscription delivered a non-IP entity into the handler.","triggerScenarios":"check() subscribes to events where the asset is not *oamnet.IPAddress (e.g. Netblock or FQDN assets) and passes them to lookup.","commonSituations":"Subscribing to broad event topics that include multiple asset types; custom data sources emitting IP-like data with a different asset struct; refactors renaming the asset type.","solutions":["In lookup/check, return nil instead of an error when the asset is not *oamnet.IPAddress so mismatched events are ignored","Tighten the event subscription filter so only IPAddress events reach lookup","Confirm upstream emitters set Asset to *oamnet.IPAddress for IP events"],"exampleFix":"// before\nip, ok := e.Entity.Asset.(*oamnet.IPAddress)\nif !ok {\n\treturn errors.New(\"failed to extract the IPAddress asset\")\n}\n\n// after\nip, ok := e.Entity.Asset.(*oamnet.IPAddress)\nif !ok {\n\treturn nil\n}","handlingStrategy":"type-guard","validationCode":"if _, ok := e.Entity.Asset.(*oamnet.IPAddress); !ok {\n\treturn nil\n}","typeGuard":"func asIPAddress(e *et.Event) (*oamnet.IPAddress, bool) {\n\tip, ok := e.Entity.Asset.(*oamnet.IPAddress)\n\treturn ip, ok\n}","tryCatchPattern":"if err := d.lookup(ev); err != nil {\n\tif strings.Contains(err.Error(), \"failed to extract the IPAddress\") {\n\t\tcontinue // not an IP event\n\t}\n\tlog.Error(err)\n}","preventionTips":["Ignore (return nil) events whose asset does not match the expected type","Register the plugin for IP-address event types only","Test handlers with mixed-type event streams"],"tags":["go","type-assertion","ip-address"],"backgroundTag":"type-mismatch","analyzedSha":"79299dce87b0085db0f2f4ef3e9c52cccb49f514","analyzedAt":"2026-09-06T08:22:48.198Z","contentChangedAt":"2026-09-06T08:22:48.198Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}