Skip to content

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
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.

4 participants