Skip to content

fix: resolution_date is earlier than created_date#4998

Merged
abeizn merged 1 commit into
apache:mainfrom
merico-ai:fix-resolution-date-is-early-than-created-date
Apr 21, 2023
Merged

fix: resolution_date is earlier than created_date#4998
abeizn merged 1 commit into
apache:mainfrom
merico-ai:fix-resolution-date-is-early-than-created-date

Conversation

@mindlesscloud
Copy link
Copy Markdown
Contributor

@mindlesscloud mindlesscloud commented Apr 21, 2023

Summary

Before going any further, let's take a look at an example.

var f struct {
    I int     `json:"i"`
    A *string `json:"a"`
}
blob1 := `{"i": 42, "a": "hello"}`
json.Unmarshal([]byte(blob1), &f)
blob2 := `{"i": 42}`
json.Unmarshal([]byte(blob2), &f)
fmt.Println(*f.A)

The output of this piece of code would be "hello", because the blob2 has no "a" key, the field f.A would keep the value set at the last time.
The ExtractExistRawData function in the GraphqlCollector suffers from the same issue. During each iteration of the loop, the same query object is being populated by a call to json.Unmarshal, causing the previous field values to persist. To fix this issue, we propose creating a new query object during each iteration of the loop.
Here's the relevant code:

query, variables, _ := collector.args.BuildQuery(nil)
for cursor.Next() {
    err = db.Fetch(cursor, row)
    err = errors.Convert(json.Unmarshal(row.Data, &query))
}

Does this close any open issues?

Closes #4988
Closes #4989

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants