cayleygraph/cayley · error
format is not supported for reading quads
Error message
format is not supported for reading quads
What it means
The v2 HTTP DELETE data endpoint needs to parse a request body of quads. It picks a format from the Content-Type header via getFormat; if no format is negotiated or the format has no registered Reader, the endpoint rejects the request with 400. Only formats compiled in / registered (e.g. nquads) provide readers.
Source
Thrown at server/http/api_v2.go:277
return
}
w.Header().Set(hdrContentType, contentTypeJSON)
response := newWriteResponse(n)
encoder := json.NewEncoder(w)
encoder.Encode(response)
}
// ServeDelete deletes data received in the request body from the database.
// Responds with how many quads were deleted.
func (api *APIv2) ServeDelete(w http.ResponseWriter, r *http.Request) {
defer r.Body.Close()
if api.ro {
jsonResponse(w, http.StatusForbidden, errors.New("database is read-only"))
return
}
format := getFormat(r, "", hdrContentType)
if format == nil || format.Reader == nil {
jsonResponse(w, http.StatusBadRequest, fmt.Errorf("format is not supported for reading quads"))
return
}
rd, err := readerFrom(r, hdrContentEncoding)
if err != nil {
jsonResponse(w, http.StatusBadRequest, err)
return
}
defer rd.Close()
qr := format.Reader(r.Body)
defer qr.Close()
h, err := api.handleForRequest(r)
if err != nil {
jsonResponse(w, http.StatusBadRequest, err)
return
}
qw := graph.NewRemover(h.QuadWriter)
defer qw.Close()
n, err := quad.CopyBatch(qw, qr, api.batch)View on GitHub (pinned to 81dcd7d73e)
Solutions
- Set Content-Type to the supported quad MIME type (e.g. application/n-quads) on the DELETE request
- Check which formats the server registered and use one with a Reader
- Inspect the response body/format list (the formats endpoint) to find an acceptable Content-Type
Example fix
// before curl -X DELETE -H 'Content-Type: application/json' --data-binary @quads.ndjson ... // after curl -X DELETE -H 'Content-Type: application/n-quads' --data-binary @quads.nq ...
Defensive patterns
Strategy: validation
Validate before calling
const ct = "application/n-quads"
req.Header.Set("Content-Type", ct)
if !strings.HasPrefix(req.Header.Get("Content-Type"), "application/") {
return errors.New("DELETE data requires a quad Content-Type")
} Try / catch
resp, err := client.Do(req)
if err != nil { return err }
if resp.StatusCode == http.StatusBadRequest {
b, _ := io.ReadAll(resp.Body)
return fmt.Errorf("data delete rejected (check Content-Type): %s", b)
} Prevention
- Always send an explicit quad-format Content-Type on DELETE /data
- Query the server's supported formats before integrating
- Share one HTTP client wrapper that sets correct headers per endpoint
When it happens
Trigger: Sending a DELETE request to /api/v2/data with an unsupported or missing Content-Type (e.g. application/json, text/plain), or omitting the Content-Type header entirely.
Common situations: API clients defaulting to JSON when posting quad deletion batches; servers built without a quad format registered; typos like application/nquads vs supported MIME strings.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- format is not supported for reading nodes
- request data is too large
- cannot remove nil value
- no support for HTTP interface for this query language
- request is too large
AI-assisted analysis of cayleygraph/cayley@81dcd7d73e (2026-09-06).
Data as JSON: /api/errors/18f34a87e6b0fafc.
Report an issue: GitHub.