owasp-amass/amass · error

unknown asset type: %s

Error message

unknown asset type: %s

What it means

parseAsset on the server decodes a raw JSON asset into the concrete oam.Asset implementation selected by the atype switch (account, domain, url, etc.). If atype matches none of the supported cases, the server returns this error, which surfaces to the AddAssetTypedHandler/AddAssetsBulkHandler callers as a request rejection.

Source

Thrown at engine/api/server/v1/utils.go:220

		return &a, err
	case strings.ToLower(string(oam.ProductRelease)):
		var a oamplat.ProductRelease
		err := json.Unmarshal(raw, &a)
		return &a, err
	case strings.ToLower(string(oam.Service)):
		var a oamplat.Service
		err := json.Unmarshal(raw, &a)
		return &a, err
	case strings.ToLower(string(oam.TLSCertificate)):
		var a oamcert.TLSCertificate
		err := json.Unmarshal(raw, &a)
		return &a, err
	case strings.ToLower(string(oam.URL)):
		var a oamurl.URL
		err := json.Unmarshal(raw, &a)
		return &a, err
	}
	return nil, fmt.Errorf("unknown asset type: %s", atype)
}

func defaultContentFilter(asset oam.Asset) (dbt.ContentFilters, error) {
	switch asset.AssetType() {
	case oam.Account:
		return dbt.ContentFilters{"unique_id": asset.Key()}, nil
	case oam.AutnumRecord:
		return dbt.ContentFilters{"handle": asset.Key()}, nil
	case oam.AutonomousSystem:
		return dbt.ContentFilters{"number": asset.Key()}, nil
	case oam.ContactRecord:
		return dbt.ContentFilters{"discovered_at": asset.Key()}, nil
	case oam.DomainRecord:
		return dbt.ContentFilters{"domain": asset.Key()}, nil
	case oam.File:
		return dbt.ContentFilters{"url": asset.Key()}, nil
	case oam.FQDN:
		return dbt.ContentFilters{"name": asset.Key()}, nil

View on GitHub (pinned to 79299dce87)

Solutions

  1. Use an oam.AssetType constant (e.g. oam.Domain, oam.IPAddress) instead of a hand-typed string.
  2. Check server version supports the asset type; upgrade the engine if the type is newer.
  3. Verify spelling/casing against the switch cases in engine/api/server/v1/utils.go parseAsset.
  4. On the client, ensure asset.AssetType() returns a registered type rather than an empty/custom value.

Example fix

// before
client.CreateAsset(ctx, token, myCustomAsset{atype: "hostname"}) // server: unknown asset type: hostname
// after
// use a supported type
a := oamdomain.Domain{Name: "example.com"}
client.CreateAsset(ctx, token, &a)
Defensive patterns

Strategy: validation

Validate before calling

supported := map[string]bool{"account":true,"autnumrecord":true /* ...all switch cases in parseAsset */}
if !supported[strings.ToLower(atype)] { return fmt.Errorf("unsupported asset type %q", atype) }

Type guard

func isKnownAssetType(atype oam.AssetType) bool {
    switch atype { case oam.Account, oam.Domain, oam.IPAddress, oam.URL /* etc */: return true }
    return false
}

Try / catch

if !isKnownAssetType(asset.AssetType()) { return fmt.Errorf("skip unsupported asset type %s", asset.AssetType()) }
_, err := client.CreateAsset(ctx, token, asset)
if err != nil && strings.Contains(err.Error(), "unknown asset type") { log skipping; return nil }

Prevention

When it happens

Trigger: POSTing an asset to /assets/{atype} (or the bulk endpoint) with an atype string that is not one of the supported oam asset types, misspelled, or in unexpected casing that still fails the lowercase comparison.

Common situations: Client and server version skew (new asset type added in client but not in server), typos in atype like "ipaddress" vs the supported constant, or hand-crafted API requests.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of owasp-amass/amass@79299dce87 (2026-09-06). Data as JSON: /api/errors/981d38ed1d071d7c. Report an issue: GitHub.