-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Closed
Labels
api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.api: loggingIssues related to the Cloud Logging API.Issues related to the Cloud Logging API.api: storageIssues related to the Cloud Storage API.Issues related to the Cloud Storage API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Description
There was a bug in the Node.js Vision client which was effectively that the client raised an exception if it ever got a key that it did not expect. This is relatively easy to do for any number of reasons:
# `raw_response` is a dict that came back from the API.
key_map = {
'alphaObject': 'alpha_object',
'betaObject': 'beta_object',
}
new_response = {}
for k, v in raw_response.iteritems():
new_response[key_map[k]] = vThis is an anti-pattern, because it strongly assumes that you will never get a new key that is not already in your key map. If the API adds a gammaObject key and this (Python) code were to run, suddenly what used to work now raises KeyError.
The solution: Add unit tests in each spot where we transform an API response into a custom object to ensure that unexpected key-value pairs are either passed through or dropped.
Metadata
Metadata
Assignees
Labels
api: datastoreIssues related to the Datastore API.Issues related to the Datastore API.api: loggingIssues related to the Cloud Logging API.Issues related to the Cloud Logging API.api: storageIssues related to the Cloud Storage API.Issues related to the Cloud Storage API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.Error or flaw in code with unintended results or allowing sub-optimal usage patterns.