{"record":{"id":"2e5c1ea8523fa9a1","repo":"owasp-amass/amass","slug":"createasset-status-s","errorCode":null,"errorMessage":"createAsset: status=%s","messagePattern":"createAsset: status=(.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/api/client/v1/client.go","lineNumber":238,"sourceCode":"\t\treturn \"\", err\n\t}\n\n\tsessionID := token.String()\n\tu := fmt.Sprintf(\"%s/sessions/%s/assets/%s\", c.base, sessionID, atype)\n\tresp, err := amasshttp.RequestWebPage(ctx, c.httpClient, &amasshttp.Request{\n\t\tURL:    u,\n\t\tBody:   string(raw),\n\t\tMethod: http.MethodPost,\n\t\tHeader: amasshttp.Header{\"Content-Type\": []string{\"application/json\"}},\n\t})\n\tif err != nil {\n\t\treturn \"\", 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 \"\", fmt.Errorf(\"createAsset: status=%s\", resp.Status)\n\t\t}\n\t\treturn \"\", fmt.Errorf(\"createAsset: status=%s error=%s\", resp.Status, msg)\n\t}\n\n\tvar r AddAssetResponse\n\tif err := json.Unmarshal([]byte(resp.Body), &r); err != nil {\n\t\treturn \"\", err\n\t}\n\treturn r.EntityID, nil\n}\n\n// Creates multiple assets in bulk on the server associated with the provided token.\nfunc (c *Client) CreateAssetsBulk(ctx context.Context, token uuid.UUID, atype string, assets []oam.Asset) (int, error) {\n\tatype = strings.ToLower(strings.TrimSpace(atype))\n\n\tif atype == \"\" {\n\t\treturn 0, fmt.Errorf(\"CreateAssetsBulk: asset type required\")\n\t}","sourceCodeStart":220,"sourceCodeEnd":256,"githubUrl":"https://github.com/owasp-amass/amass/blob/79299dce87b0085db0f2f4ef3e9c52cccb49f514/engine/api/client/v1/client.go#L220-L256","documentation":"CreateAsset POSTs a single asset to {base}/sessions/{token}/assets/{atype}. When the server returns a non-200 status and the body cannot be parsed as a JSON error, the client raises this bare status error. It means the asset was not stored and no server-side explanation was available.","triggerScenarios":"Calling Client.CreateAsset with an invalid/expired token, malformed asset JSON that the server rejects with a non-JSON error body, or a gateway/proxy returning an HTML error page (502/504).","commonSituations":"Reverse proxy timeout on large payloads, server not running the JSON error envelope version, or wrong base URL hitting an HTML 404 page.","solutions":["Check resp.Status in the message for 4xx vs 5xx to decide client vs server fix.","Verify the asset serializes correctly (asset.JSON()) and matches the atype endpoint segment.","Confirm the token maps to an active session.","Bypass or inspect any proxy between client and server that may inject HTML error pages.","Check server logs for the failed POST."],"exampleFix":"// before\nclient.CreateAsset(ctx, token, asset) // fails with bare status\n// after\nif _, err := asset.JSON(); err != nil { return fmt.Errorf(\"asset not serializable: %w\", err) }\nid, err := client.CreateAsset(ctx, token, asset)","handlingStrategy":"validation","validationCode":"raw, err := asset.JSON()\nif err != nil { return fmt.Errorf(\"asset not serializable: %w\", err) }\nif token == uuid.Nil { return errors.New(\"session token not initialized\") }","typeGuard":"func canSerialize(a oam.Asset) bool { _, err := a.JSON(); return err == nil }","tryCatchPattern":"id, err := client.CreateAsset(ctx, token, asset)\nif err != nil {\n    if strings.Contains(err.Error(), \"status=5\") { /* retry with backoff */ }\n    return fmt.Errorf(\"createAsset failed: %w\", err)\n}","preventionTips":["Validate asset JSON serialization before sending.","Keep the HTTP path free of HTML-producing proxies, or set proper Accept headers.","Ensure sessions are active before posting assets.","Monitor for 413/5xx statuses and chunk work accordingly."],"tags":["http","api-client","asset-creation"],"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"}