Skip to content

Commit 79ff3e9

Browse files
committed
address review comments
1 parent e437915 commit 79ff3e9

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pkg/processor/procbuiltin/unwrap.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ func (o *openCDCUnwrapper) UnwrapOperation(structData record.StructuredData) (re
135135
case record.Operation:
136136
operation = o
137137
case string:
138-
err := operation.UnmarshalText([]byte(o))
139-
if err != nil {
138+
if err := operation.UnmarshalText([]byte(o)); err != nil {
140139
return operation, cerrors.Errorf("couldn't unmarshal record operation")
141140
}
142141
}
@@ -176,6 +175,8 @@ func (o *openCDCUnwrapper) UnwrapKey(structData record.StructuredData) (record.D
176175
key = k
177176
case string:
178177
key = record.RawData{Raw: []byte(k)}
178+
default:
179+
return key, cerrors.Errorf("expected a record.Data or a string, got %T", k)
179180
}
180181

181182
return key, nil
@@ -212,6 +213,8 @@ func (o *openCDCUnwrapper) UnwrapPayload(structData record.StructuredData) (reco
212213
Before: nil,
213214
After: convertedData,
214215
}
216+
default:
217+
return payload, cerrors.Errorf("expected a record.Change or a map[string]interface{}, got %T", p)
215218
}
216219
return payload, nil
217220
}
@@ -223,8 +226,7 @@ func (o *openCDCUnwrapper) Unwrap(rec record.Record) (record.Record, error) {
223226
switch d := data.(type) {
224227
case record.RawData:
225228
// unmarshal raw data to structured
226-
err := json.Unmarshal(data.Bytes(), &structData)
227-
if err != nil {
229+
if err := json.Unmarshal(data.Bytes(), &structData); err != nil {
228230
return record.Record{}, cerrors.Errorf("failed to unmarshal raw data as JSON: %w", unwrapProcType, err)
229231
}
230232
case record.StructuredData:

0 commit comments

Comments
 (0)