Hi <@U04S8PLJWMT>, I am facing the following erro...
# replication-ask-ai
m
Hi @kapa.ai, I am facing the following error while trying to test my connector:
Copy code
ValueError: mutable default <class 'airbyte_cdk.sources.declarative.decoders.json_decoder.JsonDecoder'> for field _decoder is not allowed: use default_factory
k
This is a known Python dataclass issue that occurs when you use a mutable object (like
JsonDecoder
) as a default value for a dataclass field directly, instead of using
default_factory
. The Fix Instead of defining your decoder field like this:
Copy code
# ❌ Incorrect - causes the ValueError
decoder: Decoder = JsonDecoder(parameters={})
You should use `default_factory`:
Copy code
# ✅ Correct
from dataclasses import field

decoder: Decoder = field(default_factory=lambda: JsonDecoder(parameters={}))
This exact fix was applied to the
source-xero
connector's
CustomExtractor
component to resolve the same error [fix source-xero]. You can also see this pattern used consistently across multiple Airbyte connectors: • In
source-xero
`CustomExtractor`: [source-xero components] • In
source-hubspot
`HubspotPropertyHistoryExtractor`: [source-hubspot components] • In
source-monday
`MondayIncrementalItemsExtractor`: [source-monday components] Make sure you also have
field
imported from `dataclasses`:
Copy code
from dataclasses import dataclass, field
👍 0 button 👎 0 button ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.