pipecd icon indicating copy to clipboard operation
pipecd copied to clipboard

Missing error handling on json.Unmarshal inside MySQL Row Iteration

Open vedant21-oss opened this issue 7 months ago • 1 comments

Description

In the MySQL Datastore implementation, rowDataConverter.Data() blindly ignores the error returned by json.Unmarshal(jsonRaw, &obj).

If the datastore retrieves a malformed JSON slice or truncated bytes from MySQL, json.Unmarshal fails silently. Consequently, the function returns an empty or partially populated map. This leads to silent logic errors and "ghost bugs" down the pipeline instead of throwing an explicit error.

Code Context

https://github.com/pipe-cd/pipecd/blob/master/pkg/datastore/mysql/iterator.go#L86

Proposed Fix

Update the compiling interface (dataConverter) to return (map[string]interface{}, error) and bubble the failure up to the Iterator.Next() trace. I am raising a PR for this shortly.

vedant21-oss avatar Apr 21 '26 06:04 vedant21-oss

I'd like to work on this. The fix I have makes rowDataConverter.Data() return the json.Unmarshal error and propagates it through Iterator.Cursor(), with table-driven tests for malformed rows and for the cursor error path.

This is a follow-up to #6721, which went stale. @rahulshendre asked there for a test covering the Cursor() error path, so that case is included here.

harshalsp07 avatar Oct 20 '26 07:10 harshalsp07