pelias / model

Pelias data models
6 stars 17 forks source link

Incorrectly nested arrays in `name_aliases` #125

Open orangejulius opened 4 years ago

orangejulius commented 4 years ago

While running a WOF import today I noticed the following error:

error: [whosonfirst] doc generator error: invalid document type, expecting: string got: Feldbach
error: [whosonfirst] {
  "id": 1394398051,
  "name": "Liebenfels",
  "name_aliases": [
    "Liebenfels",
    [
      "Feldbach"
    ],
    "Feldbach / Liebenfels"
  ],
  "name_langs": {
    "el": [
      "Φέλντμπαχ"
    ],
    "en": [
      [
        "Feldbach"
      ],
      "Feldbach / Liebenfels"
    ],
    "nl": [
      "Feldbach"
    ],
    "ro": [
      "Feldbach"
    ]
  },
  "place_type": "neighbourhood",
  "lat": 47.24069,
  "lon": 8.78906,
  "bounding_box": "8.78906,47.24069,8.78906,47.24069",
  "population": 7,
  "hierarchies": [
    {
      "continent_id": 102191581,
      "country_id": 85633051,
      "county_id": 1394212863,
      "localadmin_id": 1394253973,
      "locality_id": 1125908497,
      "neighbourhood_id": 1394398051,
      "region_id": 85682309
    }
  ]
}

It looks like, for whatever reason, a nested array is being created in the name_aliases field:

  "name_aliases": [
    "Liebenfels",
    [
      "Feldbach"
    ],
    "Feldbach / Liebenfels"
  ],

It's unclear if the underlying error is made in the WOF importer, or here in pelias/model. Looks like we should add a .flatten to any arrays before we send them off.

missinglink commented 4 years ago

It's likely caused by the WOF data as we've seen this a few, times, before.

But yes, the pelias/model should reject these names as the expected type is a scalar string.

missinglink commented 4 years ago

The code should already be doing this although that clearly isn't working...