owasp-amass/amass · error

CreateAssetsBulk: asset type required

Error message

CreateAssetsBulk: asset type required

What it means

CreateAssetsBulk validates its atype parameter client-side before building the bulk request. An empty (or whitespace-only) asset type string cannot form the bulk endpoint path {base}/sessions/{token}/assets/{atype}:bulk, so the client fails fast with this error without any network call.

Source

Thrown at engine/api/client/v1/client.go:255

		if err != nil {
			return "", fmt.Errorf("createAsset: status=%s", resp.Status)
		}
		return "", fmt.Errorf("createAsset: status=%s error=%s", resp.Status, msg)
	}

	var r AddAssetResponse
	if err := json.Unmarshal([]byte(resp.Body), &r); err != nil {
		return "", err
	}
	return r.EntityID, nil
}

// Creates multiple assets in bulk on the server associated with the provided token.
func (c *Client) CreateAssetsBulk(ctx context.Context, token uuid.UUID, atype string, assets []oam.Asset) (int, error) {
	atype = strings.ToLower(strings.TrimSpace(atype))

	if atype == "" {
		return 0, fmt.Errorf("CreateAssetsBulk: asset type required")
	}
	if len(assets) > MaxBulkItems {
		return 0, fmt.Errorf("CreateAssetsBulk: too many items; max=%d", MaxBulkItems)
	}

	items := make([]json.RawMessage, 0, len(assets))
	for _, asset := range assets {
		if !strings.EqualFold(atype, string(asset.AssetType())) {
			return 0, fmt.Errorf("CreateAssetsBulk: mixed asset types not allowed")
		}

		raw, err := asset.JSON()
		if err != nil {
			return 0, err
		}
		items = append(items, json.RawMessage(raw))
	}

View on GitHub (pinned to 79299dce87)

Solutions

  1. Pass a non-empty asset type string, e.g. string(oam.Domain) or "domain".
  2. Trim/validate atype at the call site before invoking CreateAssetsBulk.
  3. Fix the config/env source that yielded the empty value.
  4. Ensure case is consistent (client lowercases internally, but value must be non-empty).

Example fix

// before
client.CreateAssetsBulk(ctx, token, cfgAssetType, assets)
// after
if strings.TrimSpace(cfgAssetType) == "" { return errors.New("asset type not configured") }
count, err := client.CreateAssetsBulk(ctx, token, cfgAssetType, assets)
Defensive patterns

Strategy: validation

Validate before calling

atype = strings.ToLower(strings.TrimSpace(atype))
if atype == "" { return errors.New("CreateAssetsBulk: asset type required") }

Type guard

func validBulkAtype(atype string) bool { return strings.TrimSpace(atype) != "" }

Try / catch

if err := validateAtype(atype); err != nil { return err } // pre-check
count, err := client.CreateAssetsBulk(ctx, token, atype, assets)
if err != nil { return fmt.Errorf("bulk add failed: %w", err) }

Prevention

When it happens

Trigger: Calling Client.CreateAssetsBulk(ctx, token, "", assets) or with atype containing only spaces/tabs (trimmed to empty).

Common situations: atype read from config/environment that was never set, a variable that is an empty string due to failed string parsing, or passing a nil-valued string from another layer.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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