{"record":{"id":"6c337024594c230e","repo":"owasp-amass/amass","slug":"too-many-items-in-bulk-request","errorCode":null,"errorMessage":"too many items in bulk request","messagePattern":"too many items in bulk request","errorType":"http","errorClass":null,"httpStatus":413,"severity":"error","filePath":"engine/api/server/v1/handlers.go","lineNumber":421,"sourceCode":"\tsess := v.mgr.GetSession(token)\n\tif sess == nil {\n\t\twriteError(w, http.StatusNotFound, \"session not found\", ErrNotFound)\n\t\treturn\n\t}\n\n\tvar req BulkAddAssetsRequest\n\tdec := json.NewDecoder(r.Body)\n\tif err := dec.Decode(&req); err != nil {\n\t\twriteError(w, http.StatusBadRequest, \"invalid JSON\", err)\n\t\treturn\n\t}\n\tif len(req.Items) == 0 {\n\t\twriteError(w, http.StatusBadRequest, \"items must be non-empty\", nil)\n\t\treturn\n\t}\n\tif len(req.Items) > maxBulkItems {\n\t\twriteError(w, http.StatusRequestEntityTooLarge,\n\t\t\t\"too many items in bulk request\", errors.New(\"max items exceeded\"))\n\t\treturn\n\t}\n\n\tassets := make([]oam.Asset, 0, len(req.Items))\n\tfor _, raw := range req.Items {\n\t\tif a, err := parseAsset(assetType, raw); err == nil {\n\t\t\tassets = append(assets, a)\n\t\t}\n\t}\n\n\tingested := int64(len(assets))\n\tif ingested == 0 {\n\t\twriteError(w, http.StatusBadRequest, \"no valid JSON objects in items\", nil)\n\t\treturn\n\t}\n\n\tstored, err := v.PutAssets(v.ctx, sess, assets)\n\tif err != nil {","sourceCodeStart":403,"sourceCodeEnd":439,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/engine/api/server/v1/handlers.go#L403-L439","documentation":"The bulk asset-addition endpoint enforces a hard cap of maxBulkItems items per request. When req.Items exceeds that limit, the handler responds with HTTP 413 and this message, refusing to process any of the items rather than partially ingesting them.","triggerScenarios":"POSTing to the AddAssetsBulkHandler v1 endpoint with a JSON body whose items array contains more than maxBulkItems entries.","commonSituations":"Batch scripts or integrations that dump an entire enumeration's asset list into one request; a client not paginating/chunking after a maxBulkItems constant change in a newer version.","solutions":["Split the items array into chunks of at most maxBulkItems and issue one bulk request per chunk","Check the server's maxBulkItems constant and align client batch size to it","Add client-side pagination of asset batches before calling the bulk endpoint","If 413 is persisted by an intermediate proxy, ensure the response is surfaced to the caller rather than retried"],"exampleFix":"// before\nclient.BulkAdd(allAssets) // thousands of items\n// after\nfor chunk := range lo.Chunk(allAssets, maxBulkItems) {\n    client.BulkAdd(chunk)\n}","handlingStrategy":"validation","validationCode":"if len(items) > maxBulkItems {\n    return fmt.Errorf(\"bulk request has %d items, max is %d\", len(items), maxBulkItems)\n}","typeGuard":null,"tryCatchPattern":"resp, err := client.BulkAdd(items)\nif err != nil {\n    var apiErr *APIError\n    if errors.As(err, &apiErr) && apiErr.StatusCode == http.StatusRequestEntityTooLarge {\n        // split items into chunks and retry per chunk\n    }\n}","preventionTips":["Chunk client-side batches to a size at or below maxBulkItems","Keep client batch size in sync with the server constant after upgrades","Surface HTTP 413 responses to logs instead of silently retrying"],"tags":["http","api","validation","limit"],"backgroundTag":"payload-too-large","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"}