googleapis / googleapis/google-cloud-node
Empty fields being including despite field mask
- Dominant language
- TypeScript
- Stars
- 3.2k
- Forks
- 712
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 99
Description
### Please make sure you have searched for information in the following guides.
- [x] Search the issues already opened: https://github.com/GoogleCloudPlatform/google-cloud-node/issues
- [x] Search StackOverflow: http://stackoverflow.com/questions/tagged/google-cloud-platform+node.js
- [x] Check our Troubleshooting guide: https://github.com/googleapis/google-cloud-node/blob/main/docs/troubleshooting.md
- [x] Check our FAQ: https://github.com/googleapis/google-cloud-node/blob/main/docs/faq.md
- [x] Check our libraries HOW-TO: https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md
- [x] Check out our authentication guide: https://github.com/googleapis/google-auth-library-nodejs
- [x] Check out handwritten samples for many of our APIs: https://github.com/GoogleCloudPlatform/nodejs-docs-samples
- [x] Check the API's issue tracker: https://cloud.google.com/support/docs/issue-trackers
### A screenshot that you have tested with "Try this API".
EDIT BY MAINTAINER (confirmed field masks work with try the API - used user's requests and specified addressComponents in the `fields` section on Try the API)
The field mask (`X-Goog-FieldMask`) is adhering to setting the fields returned by the functions, e.g. i didn't specify `rating` therefore it is 0.
However shouldn't the empty fields be not returned as part of the function call, e.g. `searchNearby`.
This requires manual intervention and processing to remove these unset fields.
A side question.. Where are the default values here set?
```
const fieldMask = 'places.displayName,places.addressComponents';
const request = {
includedTypes: ['coffee_shop'],
maxResultCount: 10,
regionCode: 'GB',
languageCode: 'en-GB',
rankPreference: google.maps.places.v1.SearchNearbyRequest.RankPreference.POPULARITY,
locationRestriction: {
circle: {
center: {
latitude: 50.232671229974386,
longitude: -3.765861197206113
},
radius: 1000.0
}
}
};
const callOptions = {
//autoPaginate: false,
otherArgs: {
headers: {
'X-Goog-FieldMask': fieldMask,
},
},
};
const [ resultArray, nextPageRequest, rawRespone ] = await this.#placesClient.searchNearby(request, callOptions);
console.log('searchNearby', resultArray);
```
Output includes fields not specifically requested in the field mask:
```
...
attributions: [],
currentSecondaryOpeningHours: [],
regularSecondaryOpeningHours: [],
reviews: [],
photos: [],
subDestinations: [],
containingPlaces: [],
name: '',
id: 'ChIJ9T5tCwXfbEgR8k2EaHtBkB',
nationalPhoneNumber: '',
internationalPhoneNumber: '',
formattedAddress: '',
plusCode: null,
location: null,
viewport: null,
rating: 0,
googleMapsUri: '',
websiteUri: '',
regularOpeningHours: null,
adrFormatAddress: '',
businessStatus: 'BUSINESS_STATUS_UNSPECIFIED',
priceLevel: 'PRICE_LEVEL_UNSPECIFIED',
iconMaskBaseUri: '',
...
```
### Link to the code that reproduces this issue. A link to a **public** Github Repository or gist with a minimal reproduction.
https://gist.github.com/mstephens/d3224c292e4b242e2dee38bb3bf31864
### A step-by-step description of how to reproduce the issue, based on the linked reproduction.
1. Run function `searchNearby`
### A clear and concise description of what the bug is, and what you expected to happen.
Fields not specified in field mask, to not be returned
### A clear and concise description WHY you expect this behavior, i.e., was it a recent change, there is documentation that points to this behavior, etc. **
In the same way in which the 'vanilla' `https://places.googleapis.com/v1/places:searchNearby` API operates
Contributor guide
Assessment
This issue has not been assessed yet.