projectdiscovery/nuclei · error

could not scrape and create new object: %s

Error message

could not scrape and create new object: %s

What it means

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.

Source

Thrown at pkg/js/devtools/tsgen/parser.go:194

			entity := Entity{
				Name:        k,
				Type:        "interface",
				Description: strings.TrimSpace(strings.ReplaceAll(v.Description, "Class", "interface")),
				Object: Interface{
					Properties: v.Class.Properties,
				},
			}
			p.entities = append(p.entities, entity)
		}
	}

	// handle external structs
	for k := range p.newObjects {
		// if k == "Object" {
		// 	continue
		// }
		if err := p.scrapeAndCreate(k); err != nil {
			return fmt.Errorf("could not scrape and create new object: %s", err)
		}
	}

	interfaceList := map[string]struct{}{}
	for _, v := range p.entities {
		if v.Type == "interface" {
			interfaceList[v.Name] = struct{}{}
		}
	}

	// handle method return types
	for index, v := range p.entities {
		if len(v.Class.Methods) > 0 {
			for i, method := range v.Class.Methods {
				if !strings.Contains(method.Returns, "null") {
					x := strings.TrimSpace(method.Returns)
					if _, ok := interfaceList[x]; ok {
						// non nullable interface return type detected

View on GitHub (pinned to 265b3a3dec)

Solutions

  1. Check the wrapped message for the exact type name, then make it an exported named struct inside the scanned module, or
  2. Hide the offending symbol from the generator (return a wrapper struct / keep it unexported / avoid it in the public lib surface)
  3. Re-run tsgen; if the type must stay non-struct, the scraper needs extending — report it

Example fix

// before
func (c *Client) Options() map[string]any { ... }  // map type hits scrapeAndCreate

// after
type Options struct { Key string; Value any }
func (c *Client) Options() Options { ... }
Defensive patterns

Strategy: try-catch

Try / catch

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.

Prevention

When it happens

Trigger: 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.

Common situations: Adding lib methods that expose types.Reader, generics, func types, or third-party structs; renaming a struct the generator previously scraped.

Related errors


AI-assisted analysis of projectdiscovery/nuclei@265b3a3dec (2026-08-15). Data as JSON: /api/errors/0b4beb1fca092b05. Report an issue: GitHub.