Confusing / inaccurate exception when data value has not been set

Created on 20 November 2018, about 6 years ago
Updated 24 June 2024, 7 months ago

Given:

  • Node with field "field_geo", a complex geolocation field
  • Node_empty: a node with only title. Field_geo is blank
  • Node_populated: a node with data in field_geo

Observed behavior:

  • return value from \Drupal::service('typed_data.data_fetcher')->fetchDataByPropertyPath($Node_populated->getTypedData, 'field_geo.0.lat') is the same as return value from \Drupal::service('typed_data.data_fetcher')->fetchDataByPropertyPath($Node_populated->getTypedData, 'field_geo.lat')
  • \Drupal::service('typed_data.data_fetcher')->fetchDataByPropertyPath($Node_empty->getTypedData, 'field_geo.0.lat') throws MissingDataException
  • \Drupal::service('typed_data.data_fetcher')->fetchDataByPropertyPath($Node_empty->getTypedData, 'field_geo.lat') throws InvalidArgumentException

Expected behavior:

* Using field_geo.lat should throw MissingDataException, since it is a valid selector

πŸ› Bug report
Status

Needs work

Version

2.1

Component

Data fetcher

Created by

πŸ‡ΊπŸ‡ΈUnited States AaronBauman Philadelphia

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024