Runtime ErrorAll platformsmashumaro 3.x · dbt-core 1.5+

UnserializableField: field "schema" of type Optional[str] in JsonObjectSchema is not serializable

pip install mashumaro
from mashumaro.codecs import JSONDecoder
decoder = JSONDecoder(JsonObjectSchema)
mashumaro.exceptions.UnserializableField:
field "schema" of type Optional[str] in JsonObjectSchema
is not serializable
Hint: provide a serialization strategy or use a custom codec

mashumaro's JSONCodec cannot automatically serialize fields named "schema" of type Optional[str] when the class also derives from a JSON schema base (like dbt's JsonObjectSchema). The conflict arises because "schema" is a reserved keyword in the JSON Schema specification — mashumaro's introspection treats it as a schema descriptor rather than a plain string field.

Any · mashumaro 3.x + dbt 1.5+
schema field · fails
Any · mashumaro 2.x
schema field · ok (old)

1Add SerializationStrategy for the schema fieldEasiest

Annotate the field with a pass-through SerializationStrategy to tell mashumaro to treat it as a plain string.

from dataclasses import dataclass, field
from typing import Optional
from mashumaro import DataClassJSONMixin
from mashumaro.types import SerializationStrategy

class StrPassthrough(SerializationStrategy):
    def serialize(self, value: Optional[str]) -> Optional[str]:
        return value
    def deserialize(self, value: Optional[str]) -> Optional[str]:
        return value

@dataclass
class JsonObjectSchema(DataClassJSONMixin):
    schema: Optional[str] = field(
        default=None,
        metadata={"serialize": StrPassthrough()}
    )
2Pin mashumaro to 2.x (temporary)Alternative

If the error is coming from a dependency like dbt-core, pinning mashumaro can unblock you while waiting for an upstream fix.

pip install "mashumaro<3.0"

mashumaro · Compatibility Matrix
See install results across all Python versions and operating systems
Observed in 146 searches · Last verified Aug 2026
UnserializableField: field "schema" of type Optional[str] in JsonObjectSchema is not serializable — mashumaro