Copilot commented on code in PR #4439:
URL: https://github.com/apache/flink-cdc/pull/4439#discussion_r3410761878


##########
flink-cdc-connect/flink-cdc-source-connectors/flink-connector-debezium/src/main/java/org/apache/flink/cdc/debezium/event/DebeziumEventDeserializationSchema.java:
##########
@@ -144,12 +144,29 @@ public TypeInformation<Event> getProducedType() {
     private RecordData extractBeforeDataRecord(Struct value, Schema 
valueSchema) throws Exception {
         Schema beforeSchema = fieldSchema(valueSchema, 
Envelope.FieldName.BEFORE);
         Struct beforeValue = fieldStruct(value, Envelope.FieldName.BEFORE);
+        if (beforeValue == null) {
+            throw new NullPointerException(
+                    "Before data is null for UPDATE/DELETE event. "
+                            + getNullBeforeDataHint()
+                            + "Schema name: "
+                            + valueSchema.name());
+        }

Review Comment:
   `getNullBeforeDataHint()` is concatenated directly into the exception 
message, which implicitly requires overrides to manage leading/trailing 
whitespace. This is brittle (e.g., missing/extra spaces) and also doesn’t guard 
against an override accidentally returning null. Consider normalizing the hint 
(trim + add a single separating space when non-empty) before building the 
message.



##########
flink-cdc-connect/flink-cdc-pipeline-connectors/flink-cdc-pipeline-connector-postgres/src/main/java/org/apache/flink/cdc/connectors/postgres/source/PostgresEventDeserializer.java:
##########
@@ -83,6 +83,11 @@ public PostgresEventDeserializer(
         this.databaseName = databaseName;
     }
 
+    @Override
+    protected String getNullBeforeDataHint() {
+        return "You may need to execute 'ALTER TABLE <table> REPLICA IDENTITY 
FULL' on the source table. ";
+    }

Review Comment:
   The hint string wraps the SQL statement in single quotes and has a trailing 
space. If users copy/paste the suggested `ALTER TABLE ...` from the exception 
message, the quotes will make it invalid SQL; the trailing whitespace is also 
unnecessary.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to