- Newest
- Most votes
- Most comments
The issue was that the Salesforce target's connection_options did not include the field "ID_FIELD_NAMES", which had to be set to "Id". This was not included since the documentation says this field is only needed for Upsert operations, which turns out to be false.
The error you're encountering "Index 0 out of bounds for length 0" when calling pyWriteDynamicFrame suggests there's an issue with the data being passed to the Salesforce connection.
Based on your description, there are several potential causes for this error:
-
Data Format Issue: The error might be occurring because the DynamicFrame structure doesn't match what the Salesforce connector expects. The JSON format you mentioned shows the data is present, but there might be an incompatibility with how the Salesforce connector processes it.
-
Connection Configuration: There could be an issue with the Salesforce connection configuration. The error occurs during the write operation, which suggests the problem is related to how the data is being prepared for writing to Salesforce.
-
Field Mapping: While you've renamed the fields to match Salesforce field names, there might still be a mismatch in the expected format or data types.
Here are some troubleshooting steps you can try:
-
Check CloudWatch Logs: Review the full Glue job logs in CloudWatch for additional error messages or stack traces that might provide more context about the failure.
-
Verify Salesforce Connection: Ensure that your Salesforce connection is properly configured and has the necessary permissions to perform update operations on the specified entity.
-
Data Transformation: Try explicitly converting your DynamicFrame to a specific format before writing:
# Convert to DataFrame and back to DynamicFrame to ensure proper structure df = Snowflake_source.toDF() clean_dynamic_frame = DynamicFrame.fromDF(df, glueContext, "clean_df")
-
Resource Allocation: Verify that your Glue job has sufficient resources allocated. Resource constraints can sometimes cause unexpected errors.
-
Test with a Smaller Dataset: If possible, try running the job with a simplified dataset to isolate whether it's a data-specific issue.
The error specifically mentions "pyWriteDynamicFrame" which is the method being called when you use write_dynamic_frame.from_options(). This suggests the issue is occurring at the interface between your Glue job and the Salesforce connector, likely related to how the data is being prepared or passed to Salesforce.
Sources
Error in AWS Glue ETL pipeline | AWS re:Post
An error occurred while calling o1109.pyWriteDynamicFrame - AWS Glue Job | AWS re:Post
Abstract DataSink class - AWS Glue
answered a year ago

The Salesforce connection seems to work correctly in the connection edit screen. Also, the update still fails if only the Id field is sent, so it's not likely a data issue.