When implementing configuration checking in a cust...
# replication-ask-ai
e
When implementing configuration checking in a custom connector using the python cdk, can I assume that the config contains all the values listed in my spec? Or do I have to validate they exist as well?
k
When implementing the
check
operation in your custom connector using the Python CDK, you can assume that the user-supplied configuration contains the values described in the
spec.yaml
. This means if your
spec.yaml
specifies that the source requires certain inputs, such as a
username
and
password
, the config object should contain these values. However, it's important to note that while the config object should contain the values, it doesn't guarantee that these values are valid or can be used to successfully connect to the underlying data source. Therefore, your
check
operation should verify the validity of these inputs. For example, if you're checking the validity of a currency input, you might have something like this:
Copy code
python def check_connection(self, logger, config) -> Tuple[bool, any]:    accepted_currencies = {"USD", "JPY", "BGN", "CZK", "DKK"} # assume these are the only allowed currencies    input_currency = config['base']    if input_currency not in accepted_currencies:    return False, f"Input currency {input_currency} is invalid. Please input one of the following currencies: {accepted_currencies}"    else:    return True, None
In this example, the
check_connection
function is checking if the
input_currency
from the config is in the list of
accepted_currencies
. If it's not, it returns
False
and an error message. If it is, it returns
True
and
None
. You can find more details about implementing the
check
operation in the [Airbyte documentation](https://docs.airbyte.com/connector-development/tutorials/cdk-tutorial-python-http/connection-checking).
e
@kapa.ai in other words, using that example, I do not need to check that
config
contains
base
because that has been validated somewhere upstream already?
k
New message text here