-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Solving postgres marshal/unmarshal issue #610
Conversation
Postgres datastore was not marshaling the App config during its insert, that behavior was resulting in issues when fetching the App and the datastore couldn't unmarshal the config. The same issue was probably happening with the Route's headers in some situations. This commit's idea is to always try to marshal configs and headers when inserting/updating Apps or Routes. But in Apps and Routes get methods, if the config/headers unmarshal fails, it returns an empty config/headers.
api/datastore/postgres/postgres.go
Outdated
if err := json.Unmarshal([]byte(headerStr), &route.Headers); err != nil { | ||
return err | ||
if len(configStr) > 0 { | ||
json.Unmarshal([]byte(configStr), &route.Config) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand bypassing these if they are nil/empty, but why ignore the returned errors?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, I'm changing it to return errors when unmarshaling non-empty strings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Solving postgres marshal/unmarshal issue Postgres datastore was not marshaling the App config during its insert, that behavior was resulting in issues when fetching the App and the datastore couldn't unmarshal the config. The same issue was probably happening with the Route's headers in some situations. This commit's idea is to always try to marshal configs and headers when inserting/updating Apps or Routes. But in Apps and Routes get methods, if the config/headers unmarshal fails, it returns an empty config/headers. * fix one more unmarshal case * returning error when unmarshaling non-empty
Postgres datastore was not marshaling the App config during its insert, that behavior was resulting in issues when fetching the App and the datastore couldn't unmarshal the config.
The same issue was probably happening with the Route's headers in some situations.
This commit's idea is to always try to marshal configs and headers when inserting/updating Apps or Routes. But in Apps and Routes get methods, if the config/headers unmarshal fails, it returns an empty config/headers.