Skip to content
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

Merged
merged 3 commits into from
Mar 28, 2017

Conversation

pedronasser
Copy link
Contributor

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.

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.
@pedronasser pedronasser requested a review from treeder March 28, 2017 14:36
if err := json.Unmarshal([]byte(headerStr), &route.Headers); err != nil {
return err
if len(configStr) > 0 {
json.Unmarshal([]byte(configStr), &route.Config)
}
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@jmank88 jmank88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@treeder treeder merged commit 5e8340b into master Mar 28, 2017
@treeder treeder deleted the fix-postgress-empty=app-config branch March 28, 2017 18:30
martinpinto pushed a commit to martinpinto/functions that referenced this pull request Mar 29, 2017
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants