Skip to content

SimpleUrl Harvester may crash if json object contain only decimals #9051

@f-necas

Description

@f-necas

Describe the bug

When creating an harvester pointing to https://www.data.gouv.fr/api/1/datasets/?organization=5c812a16634f416583ed1876&page_size=1 it crash because of json structure like:

followers_by_months": {
          "2024-08": 0,
...
          "2025-08": 0
},

ending up in xml

<followers_by_months>
            <2025-05>0</2025-05>
...
            <2024-12>0</2024-12>
            <2025-02>0</2025-02>
</followers_by_months>

which isn't valid, because xml tags :

  • Start with a letter or underscore (_)
  • Can contain letters, digits, hyphens (-), underscores (_), and periods (.)
  • Cannot start with a number

Maybe in https://github.com/geonetwork/core-geonetwork/blob/main/harvesters/src/main/java/org/fao/geonet/kernel/harvest/harvester/simpleurl/Harvester.java#L370

It could be added something like .replaceAll("<(/?)([\\d-]*)>", "<$1_$2>");

To Reproduce
Steps to reproduce the behavior:

  1. Go to Harvesters
  2. Url https://www.data.gouv.fr/api/1/datasets/?organization=5c812a16634f416583ed1876&page_size=1
  3. Loop /data
  4. Id /id

Expected behavior
A metadata harvested

Log file
Error on line 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions