This section provides troubleshooting guidance for common issues encountered
when using a
[Cloud Storage Sink connector](https://docs.cloud.google.com/managed-service-for-apache-kafka/docs/connect-cluster/create-cloud-storage-connector.md.txt).

## Deserialization is misconfigured

If the connector's converters don't match the data in Kafka, the connector fails
with an error message similar to the following:

    org.apache.kafka.connect.errors.DataException: Converting byte[] to Kafka
    Connect data failed due to serialization error:

To resolve this issue, make sure the [key and value converters](https://docs.cloud.google.com/managed-service-for-apache-kafka/docs/connect-cluster/connectors-overview.md.txt#converters) for the
connector match the data that the connector is reading from Kafka.

For example, if you set the format output type to `csv` and the value converter
to `JsonConverter`, you might see the following error:

    org.apache.kafka.connect.errors.DataException: Converting byte[] to Kafka
    Connect data failed due to serialization error:
    at org.apache.kafka.connect.json.JsonConverter.toConnectData(JsonConverter.java:333)
    at org.apache.kafka.connect.storage.Converter.toConnectData(Converter.java:91)

This error occurs because CSV output requires `ByteArrayConverter` for the value
converter, not `JsonConverter`. For more information, see
[How a Cloud Storage Sink connector works](https://docs.cloud.google.com/managed-service-for-apache-kafka/docs/connect-cluster/create-cloud-storage-connector.md.txt#storage-sink-connector).

The stack trace in the logs might help to locate the root cause. For example,
the following log entry indicates a problem converting a UTF-32 character:

    Caused by: org.apache.kafka.common.errors.SerializationException:
    java.io.CharConversionException: Invalid UTF-32 character 0x31d086a
    (above 0x0010ffff) at char #1, byte #7

## Missing Cloud Storage bucket permissions

If the Managed Kafka service account doesn't have permission to write to the
Cloud Storage bucket, the connector fails with an error message similar
to the following:

    org.apache.kafka.connect.errors.ConnectException:
    com.google.cloud.storage.StorageException: 403 Forbidden

To resolve this issue, grant the **Storage Object Creator** role
(`roles/storage.objectCreator`) to the Managed Kafka service account. For more
information, see
[Grant permissions to write to the Cloud Storage bucket](https://docs.cloud.google.com/managed-service-for-apache-kafka/docs/connect-cluster/create-cloud-storage-connector.md.txt#grant-storage-permissions).

## Missing Cloud Storage credentials

If the connector configuration doesn't include `gcs.credentials.default=true`,
the connector fails with an error message similar to the following:

    org.apache.kafka.connect.errors.ConnectException:
    com.google.cloud.storage.StorageException: 401 Unauthorized

To resolve this issue, add `gcs.credentials.default=true` to the connector's
configuration settings.

## What's next

- [Troubleshoot Connect clusters and connectors](https://docs.cloud.google.com/managed-service-for-apache-kafka/docs/connect-cluster/troubleshoot-kafka-connect.md.txt)
- [Create a Cloud Storage sink connector](https://docs.cloud.google.com/managed-service-for-apache-kafka/docs/connect-cluster/create-cloud-storage-connector.md.txt)

*Apache Kafka® is a registered
trademark of The Apache Software Foundation or its affiliates in the United
States and/or other countries.*