{"record":{"id":"5e0840139925b2c5","repo":"owasp-amass/amass","slug":"addassetsbulk-status-s","errorCode":null,"errorMessage":"addAssetsBulk: status=%s","messagePattern":"addAssetsBulk: status=(.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/api/client/v1/client.go","lineNumber":290,"sourceCode":"\t}\n\n\tsessionID := token.String()\n\tbody, _ := json.Marshal(BulkAddAssetsRequest{Items: items})\n\tu := fmt.Sprintf(\"%s/sessions/%s/assets/%s:bulk\", c.base, sessionID, atype)\n\tresp, err := amasshttp.RequestWebPage(ctx, c.httpClient, &amasshttp.Request{\n\t\tURL:    u,\n\t\tBody:   string(body),\n\t\tMethod: http.MethodPost,\n\t\tHeader: amasshttp.Header{\"Content-Type\": []string{\"application/json\"}},\n\t})\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\n\tif resp.StatusCode != http.StatusOK {\n\t\tmsg, err := readJSONError(resp.Body)\n\t\tif err != nil {\n\t\t\treturn 0, fmt.Errorf(\"addAssetsBulk: status=%s\", resp.Status)\n\t\t}\n\t\treturn 0, fmt.Errorf(\"addAssetsBulk: status=%s error=%s\", resp.Status, msg)\n\t}\n\n\tvar out BulkAddAssetsResponse\n\tif err := json.Unmarshal([]byte(resp.Body), &out); err != nil {\n\t\treturn 0, err\n\t}\n\treturn int(out.Stored), nil\n}\n\n// Subscribe to receive a stream of log messages from the server.\nfunc (c *Client) Subscribe(ctx context.Context, token uuid.UUID) (<-chan string, error) {\n\tu, err := url.Parse(c.base)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/engine/api/client/v1/client.go#L272-L308","documentation":"CreateAssetsBulk POSTs the batch to {base}/sessions/{token}/assets/{atype}:bulk. When the server responds non-200 and the body cannot be parsed as a JSON error, the client raises this bare status error; none (or only some) of the assets were stored and no server explanation is available.","triggerScenarios":"Calling CreateAssetsBulk when the server rejects the bulk POST with a non-JSON body — unknown session (401/404 HTML page), request entity too large (413 from proxy), or 5xx with empty body.","commonSituations":"Oversized bulk payload rejected by a reverse proxy with an HTML error page, server crash mid-request returning an empty 500, or stale token after server restart.","solutions":["Check the HTTP status in the message; 413/502 usually means the batch is too large — chunk it further.","Verify the token is from an active session.","Inspect server/proxy logs for the failing request.","Retry with smaller batches on 5xx.","Ensure the server version supports the :bulk endpoint."],"exampleFix":"// before\ncount, err := client.CreateAssetsBulk(ctx, token, atype, assets) // bare status error\n// after\nconst chunk = 100\nfor i := 0; i < len(assets); i += chunk {\n    end := min(i+chunk, len(assets))\n    if _, err := client.CreateAssetsBulk(ctx, token, atype, assets[i:end]); err != nil { return err }\n}","handlingStrategy":"retry","validationCode":"if token == uuid.Nil { return errors.New(\"session token not initialized\") }\nif len(assets) == 0 || len(assets) > MaxBulkItems { return errors.New(\"invalid bulk batch size\") }","typeGuard":"func isTransientStatus(err error) bool { s := err.Error(); return strings.Contains(s, \"status=502\") || strings.Contains(s, \"status=503\") || strings.Contains(s, \"status=504\") }","tryCatchPattern":"count, err := client.CreateAssetsBulk(ctx, token, atype, assets)\nif err != nil && isTransientStatus(err) {\n    return retryWithBackoff(3, func() error { _, err = client.CreateAssetsBulk(ctx, token, atype, assets); return err })\n}","preventionTips":["Retry only transient 5xx failures with exponential backoff.","Split very large batches to avoid proxy body-size limits (413).","Keep sessions alive across long bulk operations.","Correlate failures with server logs via timestamps."],"tags":["http","api-client","bulk-assets"],"backgroundTag":"http-error-response","analyzedSha":"79299dce87b0085db0f2f4ef3e9c52cccb49f514","analyzedAt":"2026-09-06T08:22:48.198Z","contentChangedAt":"2026-09-06T08:22:48.198Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}