{"record":{"id":"d5de0e172596f6ed","repo":"cayleygraph/cayley","slug":"format-is-not-supported-for-reading-nodes","errorCode":null,"errorMessage":"format is not supported for reading nodes","messagePattern":"format is not supported for reading nodes","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"server/http/api_v2.go","lineNumber":314,"sourceCode":"\tif err != nil {\n\t\tjsonResponse(w, http.StatusInternalServerError, err)\n\t\treturn\n\t}\n\tw.Header().Set(hdrContentType, contentTypeJSON)\n\tfmt.Fprintf(w, `{\"result\": \"Successfully deleted %d quads.\", \"count\": %d}`+\"\\n\", n, n)\n}\n\n// ServeNodeDelete deletes all data associated with a node (an entity).\n// Responds with how many quads were deleted.\nfunc (api *APIv2) ServeNodeDelete(w http.ResponseWriter, r *http.Request) {\n\tdefer r.Body.Close()\n\tif api.ro {\n\t\tjsonResponse(w, http.StatusForbidden, errors.New(\"database is read-only\"))\n\t\treturn\n\t}\n\tformat := getFormat(r, \"\", hdrContentType)\n\tif format == nil || format.UnmarshalValue == nil {\n\t\tjsonResponse(w, http.StatusBadRequest, fmt.Errorf(\"format is not supported for reading nodes\"))\n\t\treturn\n\t}\n\tconst limit = 128*1024 + 1\n\trd := io.LimitReader(r.Body, limit)\n\tdata, err := ioutil.ReadAll(rd)\n\tif err != nil {\n\t\tjsonResponse(w, http.StatusBadRequest, err)\n\t\treturn\n\t} else if len(data) == limit {\n\t\tjsonResponse(w, http.StatusBadRequest, fmt.Errorf(\"request data is too large\"))\n\t\treturn\n\t}\n\tv, err := format.UnmarshalValue(data)\n\tif err != nil {\n\t\tjsonResponse(w, http.StatusBadRequest, err)\n\t\treturn\n\t} else if v == nil {\n\t\tjsonResponse(w, http.StatusBadRequest, fmt.Errorf(\"cannot remove nil value\"))","sourceCodeStart":296,"sourceCodeEnd":332,"githubUrl":"https://github.com/cayleygraph/cayley/blob/81dcd7d73e45136bc0d01802a8ba4685d8a533eb/server/http/api_v2.go#L296-L332","documentation":"The v2 HTTP node-delete endpoint reads a single node value from the request body and needs a format with UnmarshalValue. If the Content-Type does not map to a format capable of unmarshaling node values, the endpoint returns 400 with this message.","triggerScenarios":"Sending a DELETE to /api/v2/node with a Content-Type whose format lacks UnmarshalValue (e.g. quad-oriented formats like nquads instead of a node format like JSON), or with an unknown/missing Content-Type.","commonSituations":"Clients reusing the data endpoint's Content-Type for the node endpoint; servers without JSON format registered; header typos or missing charset handling.","solutions":["Set Content-Type to a node-capable format (e.g. application/json) on the node DELETE request","Verify the server registered the format with UnmarshalValue support","Use /api/v2/data with a quad Reader format instead if deleting a batch of quads"],"exampleFix":"// before\ncurl -X DELETE -H 'Content-Type: application/n-quads' --data '\"n1\"' .../node\n// after\ncurl -X DELETE -H 'Content-Type: application/json' --data '\"n1\"' .../node","handlingStrategy":"validation","validationCode":"req.Header.Set(\"Content-Type\", \"application/json\") // node endpoint needs a value format","typeGuard":null,"tryCatchPattern":"resp, err := client.Do(req)\nif err != nil { return err }\nif resp.StatusCode == http.StatusBadRequest {\n    b, _ := io.ReadAll(resp.Body)\n    if strings.Contains(string(b), \"reading nodes\") {\n        return fmt.Errorf(\"use application/json for node delete: %s\", b)\n    }\n    return fmt.Errorf(\"node delete rejected: %s\", b)\n}","preventionTips":["Use application/json for /node endpoints and quad formats for /data endpoints","Do not copy headers between the data and node API calls","Verify server format registration (JSON with UnmarshalValue) before using node delete"],"tags":["http","api","content-type"],"backgroundTag":"unsupported-operation","analyzedSha":"81dcd7d73e45136bc0d01802a8ba4685d8a533eb","analyzedAt":"2026-09-06T06:14:12.358Z","contentChangedAt":"2026-09-06T06:14:12.358Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}