{"record":{"id":"0b4beb1fca092b05","repo":"projectdiscovery/nuclei","slug":"could-not-scrape-and-create-new-object-s","errorCode":null,"errorMessage":"could not scrape and create new object: %s","messagePattern":"could not scrape and create new object: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/js/devtools/tsgen/parser.go","lineNumber":194,"sourceCode":"\t\t\tentity := Entity{\n\t\t\t\tName:        k,\n\t\t\t\tType:        \"interface\",\n\t\t\t\tDescription: strings.TrimSpace(strings.ReplaceAll(v.Description, \"Class\", \"interface\")),\n\t\t\t\tObject: Interface{\n\t\t\t\t\tProperties: v.Class.Properties,\n\t\t\t\t},\n\t\t\t}\n\t\t\tp.entities = append(p.entities, entity)\n\t\t}\n\t}\n\n\t// handle external structs\n\tfor k := range p.newObjects {\n\t\t// if k == \"Object\" {\n\t\t// \tcontinue\n\t\t// }\n\t\tif err := p.scrapeAndCreate(k); err != nil {\n\t\t\treturn fmt.Errorf(\"could not scrape and create new object: %s\", err)\n\t\t}\n\t}\n\n\tinterfaceList := map[string]struct{}{}\n\tfor _, v := range p.entities {\n\t\tif v.Type == \"interface\" {\n\t\t\tinterfaceList[v.Name] = struct{}{}\n\t\t}\n\t}\n\n\t// handle method return types\n\tfor index, v := range p.entities {\n\t\tif len(v.Class.Methods) > 0 {\n\t\t\tfor i, method := range v.Class.Methods {\n\t\t\t\tif !strings.Contains(method.Returns, \"null\") {\n\t\t\t\t\tx := strings.TrimSpace(method.Returns)\n\t\t\t\t\tif _, ok := interfaceList[x]; ok {\n\t\t\t\t\t\t// non nullable interface return type detected","sourceCodeStart":176,"sourceCodeEnd":212,"githubUrl":"https://github.com/projectdiscovery/nuclei/blob/265b3a3dec374741614e342f813c10f8b38d2bb7/pkg/js/devtools/tsgen/parser.go#L176-L212","documentation":"While resolving 'external objects' — Go types referenced by a lib's API surface but defined elsewhere — tsgen's scrapeAndCreate(k) failed for type k. The wrapped error is typically 'type X not found in package Y' or 'X is not a named struct type' from the scraper (see error 198), meaning the referenced type is not an exported struct reachable in the scanned package.","triggerScenarios":"A lib method returning/accepting a named type whose underlying kind is not a struct (interface, map, slice, alias), or a type that lives in another package the scraper cannot reach from the module dir.","commonSituations":"Adding lib methods that expose types.Reader, generics, func types, or third-party structs; renaming a struct the generator previously scraped.","solutions":["Check the wrapped message for the exact type name, then make it an exported named struct inside the scanned module, or","Hide the offending symbol from the generator (return a wrapper struct / keep it unexported / avoid it in the public lib surface)","Re-run tsgen; if the type must stay non-struct, the scraper needs extending — report it"],"exampleFix":"// before\nfunc (c *Client) Options() map[string]any { ... }  // map type hits scrapeAndCreate\n\n// after\ntype Options struct { Key string; Value any }\nfunc (c *Client) Options() Options { ... }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"When patching the generator, wrap scrapeAndCreate per-type and downgrade failures for non-struct externals to warnings (skip + log the type name) instead of failing the whole run.","preventionTips":["Expose only concrete named structs in lib API surfaces","Wrap non-struct returns (maps, slices, interfaces) in a struct","After adding methods, run tsgen early to catch unscrapable types before they spread"],"tags":["devtools","tsgen","code-generation","go-types"],"backgroundTag":null,"analyzedSha":"265b3a3dec374741614e342f813c10f8b38d2bb7","analyzedAt":"2026-08-15T20:05:51.855Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}