#17614·saleor

Bug: richText field returns unexpected Cast(CASE...) string instead of JSON

Author: saifulDevsCreated Apr 16, 2025Updated Jul 27, 2026
Labelsbugtriage

What are you trying to achieve?

Description When querying a product's attribute values with richText, instead of returning actual JSON, the API returns a stringified SQL expression like:

json

"richText": "\"Cast(CASE WHEN <WhereNode: (AND: Exact(Col(attribute_attributevalue, attribute.AttributeValue.id), 181))> THEN Value({...}), ELSE Value(None))\""
This makes the richText field unusable in frontends or other systems expecting actual JSON conten

Steps to reproduce the problem

Update a product attribute using the productUpdate mutation with richText value.

Query the product's attributes and request values { richText }.

Observe the output of the richText field.

✅ Expected Behavior The API should return the real JSON content stored in the richText field, such as:

{
  "time": 1744793604060,
  "blocks": [{ "type": "paragraph", "data": { "text": "new test" } }],
  "version": "2.24.3"
}

❌ Actual Behavior Instead of JSON, it returns a stringified Django ORM annotation:

"\"Cast(CASE WHEN <WhereNode: (AND: Exact(Col(...)))> THEN Value(...), ELSE Value(None))\""
 Possible Cause

This may be caused by using annotate() with Case + Cast in the queryset, which does not serialize cleanly through GraphQL resolvers.

Environment Saleor Version: 3.20.0

Database: PostgreSQL

Mutation Used: productUpdate

Field Affected: AttributeValue.richText

What did you expect to happen?

Additional Context Please advise how to get the actual JSON from richText. Is this a bug in how annotations are exposed via GraphQL, or is there a workaround?

Logs

No response

Environment

Saleor version: 3.20.0-a.0 OS and version: …