Skip to content

Empty fields being including despite field mask #6592

@mstephens

Description

@mstephens

Please make sure you have searched for information in the following guides.

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)

Image

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p2Moderately-important priority. Fix may not be included in next release.size: stype: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions