Repository: opendatacube/datacube-core

Issue:
product add failing validation message is unclear
### Expected behaviour

When product add is failing validation, console should specify which `Failed validating 'oneOf' in schema['properties']['measurements']['items']['properties']['spectral_definition']:` instead of stating `oneOf` 


### Actual behaviour

`Failed validating 'oneOf' in schema['properties']['measurements']['items']['properties']['spectral_definition']:` is not specific enough

```
(odc) [odcadmin@odc-app01p tmp]$ datacube product add s2a_ard_granule.odc-product.yaml
2022-06-29 11:37:22,136 409694 datacube-product ERROR {'response': ['7e-06', '7e-06', '8e-06', 2.8e-05, 3.8e-05, 9.1e-05, 0.000147, 0.000251, 0.00048, 0.00057, 0.000662, 0.000911, 0.001166, 0.001684, 0.002458, 0.003567, 0.005345, 0.008318, 0.012628, 0.018996, 0.027781, 0.039584, 0.054865, 0.07493, 0.10107, 0.135476, 0.182597, 0.247276, 0.330736, 0.429691, 0.537634, 0.647173, 0.743528, 0.815215, 0.859202, 0.879669, 0.88703, 0.889098, 0.891417, 0.897586, 0.906631, 0.916528, 0.926579, 0.935322, 0.942394, 0.947507, 0.951416, 0.954254, 0.956429, 0.958205, 0.960688, 0.96348, 0.965797, 0.96818, 0.971012, 0.97338, 0.975915, 0.978581, 0.979878, 0.980589, 0.980912, 0.981412, 0.981244, 0.980705, 0.980377, 0.981066, 0.982736, 0.985122, 0.987807, 0.990376, 0.992016, 0.993288, 0.992536, 0.990405, 0.987128, 0.983502, 0.980023, 0.976174, 0.972568, 0.969828, 0.967709, 0.966371, 0.965849, 0.96605, 0.967427, 0.96987, 0.973463, 0.978683, 0.983472, 0.987635, 0.991875, 0.995476, 0.997586, 0.998568, 0.999328, 0.999234, 0.998804, 0.999111, 0.99973, 0.999745, 1.0, 0.999814, 0.996693, 0.99162, 0.985702, 0.978569, 0.969903, 0.960896, 0.953287, 0.946546, 0.941712, 0.938586, 0.935489, 0.928114, 0.912102, 0.880598, 0.82498, 0.743118, 0.641891, 0.534002, 0.426963, 0.32371, 0.234284, 0.163972, 0.110211, 0.072478, 0.046194, 0.029401, 0.019359, 0.013308, 0.009317, 0.006523, 0.004864, 0.003409, 0.002491, 0.001958, 0.001423, 0.001055, 0.000498, 0.000228, 0.000159, 3.4e-05, 4.5e-05, 1.3e-05], 'wavelength': [1539, 1540, 1541, 1542, 1543, 1544, 1545, 1546, 1547, 1548, 1549, 1550, 1551, 1552, 1553, 1554, 1555, 1556, 1557, 1558, 1559, 1560, 1561, 1562, 1563, 1564, 1565, 1566, 1567, 1568, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 1591, 1592, 1593, 1594, 1595, 1596, 1597, 1598, 1599, 1600, 1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615, 1616, 1617, 1618, 1619, 1620, 1621, 1622, 1623, 1624, 1625, 1626, 1627, 1628, 1629, 1630, 1631, 1632, 1633, 1634, 1635, 1636, 1637, 1638, 1639, 1640, 1641, 1642, 1643, 1644, 1645, 1646, 1647, 1648, 1649, 1650, 1651, 1652, 1653, 1654, 1655, 1656, 1657, 1658, 1659, 1660, 1661, 1662, 1663, 1664, 1665, 1666, 1667, 1668, 1669, 1670, 1671, 1672, 1673, 1674, 1675, 1676, 1677, 1678, 1679, 1680, 1681, 1682]} is not valid under any of the given schemas

Failed validating 'oneOf' in schema['properties']['measurements']['items']['properties']['spectral_definition']:
    {'oneOf': [{'$ref': '#/definitions/spectral_definition'},
               {'description': 'List of spectral definitions, one per '
                               'coordinate.',
                'items': {'$ref': '#/definitions/spectral_definition'},
                'type': 'array'}]}

On instance['measurements'][22]['spectral_definition']:
    {'response': ['7e-06',
                  '7e-06',
                  '8e-06',
                  2.8e-05,
                  3.8e-05,
                  9.1e-05,
                  0.000147,
                  0.000251,
                  0.00048,
                  0.00057,
                  0.000662,
                  0.000911,
                  0.001166,
                  0.001684,
                  0.002458,
                  0.003567,
                  0.005345,
                  0.008318,
                  0.012628,
                  0.018996,
                  0.027781,
                  0.039584,
                  0.054865,
                  0.07493,
                  0.10107,
                  0.135476,
                  0.182597,
                  0.247276,
                  0.330736,
                  0.429691,
                  0.537634,
                  0.647173,
                  0.743528,
                  0.815215,
                  0.859202,
                  0.879669,
                  0.88703,
                  0.889098,
                  0.891417,
                  0.897586,
                  0.906631,
                  0.916528,
                  0.926579,
                  0.935322,
                  0.942394,
                  0.947507,
                  0.951416,
                  0.954254,
                  0.956429,
                  0.958205,
                  0.960688,
                  0.96348,
                  0.965797,
                  0.96818,
                  0.971012,
                  0.97338,
                  0.975915,
                  0.978581,
                  0.979878,
                  0.980589,
                  0.980912,
                  0.981412,
                  0.981244,
                  0.980705,
                  0.980377,
                  0.981066,
                  0.982736,
                  0.985122,
                  0.987807,
                  0.990376,
                  0.992016,
                  0.993288,
                  0.992536,
                  0.990405,
                  0.987128,
                  0.983502,
                  0.980023,
                  0.976174,
                  0.972568,
                  0.969828,
                  0.967709,
                  0.966371,
                  0.965849,
                  0.96605,
                  0.967427,
                  0.96987,
                  0.973463,
                  0.978683,
                  0.983472,
                  0.987635,
                  0.991875,
                  0.995476,
                  0.997586,
                  0.998568,
                  0.999328,
                  0.999234,
                  0.998804,
                  0.999111,
                  0.99973,
                  0.999745,
                  1.0,
                  0.999814,
                  0.996693,
                  0.99162,
                  0.985702,
                  0.978569,
                  0.969903,
                  0.960896,
                  0.953287,
                  0.946546,
                  0.941712,
                  0.938586,
                  0.935489,
                  0.928114,
                  0.912102,
                  0.880598,
                  0.82498,
                  0.743118,
                  0.641891,
                  0.534002,
                  0.426963,
                  0.32371,
                  0.234284,
                  0.163972,
                  0.110211,
                  0.072478,
                  0.046194,
                  0.029401,
                  0.019359,
                  0.013308,
                  0.009317,
                  0.006523,
                  0.004864,
                  0.003409,
                  0.002491,
                  0.001958,
                  0.001423,
                  0.001055,
                  0.000498,
                  0.000228,
                  0.000159,
                  3.4e-05,
                  4.5e-05,
                  1.3e-05],
     'wavelength': [1539,
                    1540,
                    1541,
                    1542,
                    1543,
                    1544,
                    1545,
                    1546,
                    1547,
                    1548,
                    1549,
                    1550,
                    1551,
                    1552,
                    1553,
                    1554,
                    1555,
                    1556,
                    1557,
                    1558,
                    1559,
                    1560,
                    1561,
                    1562,
                    1563,
                    1564,
                    1565,
                    1566,
                    1567,
                    1568,
                    1569,
                    1570,
                    1571,
                    1572,
                    1573,
                    1574,
                    1575,
                    1576,
                    1577,
                    1578,
                    1579,
                    1580,
                    1581,
                    1582,
                    1583,
                    1584,
                    1585,
                    1586,
                    1587,
                    1588,
                    1589,
                    1590,
                    1591,
                    1592,
                    1593,
                    1594,
                    1595,
                    1596,
                    1597,
                    1598,
                    1599,
                    1600,
                    1601,
                    1602,
                    1603,
                    1604,
                    1605,
                    1606,
                    1607,
                    1608,
                    1609,
                    1610,
                    1611,
                    1612,
                    1613,
                    1614,
                    1615,
                    1616,
                    1617,
                    1618,
                    1619,
                    1620,
                    1621,
                    1622,
                    1623,
                    1624,
                    1625,
                    1626,
                    1627,
                    1628,
                    1629,
                    1630,
                    1631,
                    1632,
                    1633,
                    1634,
                    1635,
                    1636,
                    1637,
                    1638,
                    1639,
                    1640,
                    1641,
                    1642,
                    1643,
                    1644,
                    1645,
                    1646,
                    1647,
                    1648,
                    1649,
                    1650,
                    1651,
                    1652,
                    1653,
                    1654,
                    1655,
                    1656,
                    1657,
                    1658,
                    1659,
                    1660,
                    1661,
                    1662,
                    1663,
                    1664,
                    1665,
                    1666,
                    1667,
                    1668,
                    1669,
                    1670,
                    1671,
                    1672,
                    1673,
                    1674,
                    1675,
                    1676,
                    1677,
                    1678,
                    1679,
                    1680,
                    1681,
                    1682]}
Traceback (most recent call last):
  File "/home/odcadmin/miniconda3/envs/odc/lib/python3.9/site-packages/datacube/utils/documents.py", line 219, in validate_document
    validator.validate(document)
  File "/home/odcadmin/miniconda3/envs/odc/lib/python3.9/site-packages/jsonschema/validators.py", line 267, in validate
    raise error
jsonschema.exceptions.ValidationError: {'response': ['7e-06', '7e-06', '8e-06', 2.8e-05, 3.8e-05, 9.1e-05, 0.000147, 0.000251, 0.00048, 0.00057, 0.000662, 0.000911, 0.001166, 0.001684, 0.002458, 0.003567, 0.005345, 0.008318, 0.012628, 0.018996, 0.027781, 0.039584, 0.054865, 0.07493, 0.10107, 0.135476, 0.182597, 0.247276, 0.330736, 0.429691, 0.537634, 0.647173, 0.743528, 0.815215, 0.859202, 0.879669, 0.88703, 0.889098, 0.891417, 0.897586, 0.906631, 0.916528, 0.926579, 0.935322, 0.942394, 0.947507, 0.951416, 0.954254, 0.956429, 0.958205, 0.960688, 0.96348, 0.965797, 0.96818, 0.971012, 0.97338, 0.975915, 0.978581, 0.979878, 0.980589, 0.980912, 0.981412, 0.981244, 0.980705, 0.980377, 0.981066, 0.982736, 0.985122, 0.987807, 0.990376, 0.992016, 0.993288, 0.992536, 0.990405, 0.987128, 0.983502, 0.980023, 0.976174, 0.972568, 0.969828, 0.967709, 0.966371, 0.965849, 0.96605, 0.967427, 0.96987, 0.973463, 0.978683, 0.983472, 0.987635, 0.991875, 0.995476, 0.997586, 0.998568, 0.999328, 0.999234, 0.998804, 0.999111, 0.99973, 0.999745, 1.0, 0.999814, 0.996693, 0.99162, 0.985702, 0.978569, 0.969903, 0.960896, 0.953287, 0.946546, 0.941712, 0.938586, 0.935489, 0.928114, 0.912102, 0.880598, 0.82498, 0.743118, 0.641891, 0.534002, 0.426963, 0.32371, 0.234284, 0.163972, 0.110211, 0.072478, 0.046194, 0.029401, 0.019359, 0.013308, 0.009317, 0.006523, 0.004864, 0.003409, 0.002491, 0.001958, 0.001423, 0.001055, 0.000498, 0.000228, 0.000159, 3.4e-05, 4.5e-05, 1.3e-05], 'wavelength': [1539, 1540, 1541, 1542, 1543, 1544, 1545, 1546, 1547, 1548, 1549, 1550, 1551, 1552, 1553, 1554, 1555, 1556, 1557, 1558, 1559, 1560, 1561, 1562, 1563, 1564, 1565, 1566, 1567, 1568, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 1591, 1592, 1593, 1594, 1595, 1596, 1597, 1598, 1599, 1600, 1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615, 1616, 1617, 1618, 1619, 1620, 1621, 1622, 1623, 1624, 1625, 1626, 1627, 1628, 1629, 1630, 1631, 1632, 1633, 1634, 1635, 1636, 1637, 1638, 1639, 1640, 1641, 1642, 1643, 1644, 1645, 1646, 1647, 1648, 1649, 1650, 1651, 1652, 1653, 1654, 1655, 1656, 1657, 1658, 1659, 1660, 1661, 1662, 1663, 1664, 1665, 1666, 1667, 1668, 1669, 1670, 1671, 1672, 1673, 1674, 1675, 1676, 1677, 1678, 1679, 1680, 1681, 1682]} is not valid under any of the given schemas

Failed validating 'oneOf' in schema['properties']['measurements']['items']['properties']['spectral_definition']:
    {'oneOf': [{'$ref': '#/definitions/spectral_definition'},
               {'description': 'List of spectral definitions, one per '
                               'coordinate.',
                'items': {'$ref': '#/definitions/spectral_definition'},
                'type': 'array'}]}

On instance['measurements'][22]['spectral_definition']:
    {'response': ['7e-06',
                  '7e-06',
                  '8e-06',
                  2.8e-05,
                  3.8e-05,
                  9.1e-05,
                  0.000147,
                  0.000251,
                  0.00048,
                  0.00057,
                  0.000662,
                  0.000911,
                  0.001166,
                  0.001684,
                  0.002458,
                  0.003567,
                  0.005345,
                  0.008318,
                  0.012628,
                  0.018996,
                  0.027781,
                  0.039584,
                  0.054865,
                  0.07493,
                  0.10107,
                  0.135476,
                  0.182597,
                  0.247276,
                  0.330736,
                  0.429691,
                  0.537634,
                  0.647173,
                  0.743528,
                  0.815215,
                  0.859202,
                  0.879669,
                  0.88703,
                  0.889098,
                  0.891417,
                  0.897586,
                  0.906631,
                  0.916528,
                  0.926579,
                  0.935322,
                  0.942394,
                  0.947507,
                  0.951416,
                  0.954254,
                  0.956429,
                  0.958205,
                  0.960688,
                  0.96348,
                  0.965797,
                  0.96818,
                  0.971012,
                  0.97338,
                  0.975915,
                  0.978581,
                  0.979878,
                  0.980589,
                  0.980912,
                  0.981412,
                  0.981244,
                  0.980705,
                  0.980377,
                  0.981066,
                  0.982736,
                  0.985122,
                  0.987807,
                  0.990376,
                  0.992016,
                  0.993288,
                  0.992536,
                  0.990405,
                  0.987128,
                  0.983502,
                  0.980023,
                  0.976174,
                  0.972568,
                  0.969828,
                  0.967709,
                  0.966371,
                  0.965849,
                  0.96605,
                  0.967427,
                  0.96987,
                  0.973463,
                  0.978683,
                  0.983472,
                  0.987635,
                  0.991875,
                  0.995476,
                  0.997586,
                  0.998568,
                  0.999328,
                  0.999234,
                  0.998804,
                  0.999111,
                  0.99973,
                  0.999745,
                  1.0,
                  0.999814,
                  0.996693,
                  0.99162,
                  0.985702,
                  0.978569,
                  0.969903,
                  0.960896,
                  0.953287,
                  0.946546,
                  0.941712,
                  0.938586,
                  0.935489,
                  0.928114,
                  0.912102,
                  0.880598,
                  0.82498,
                  0.743118,
                  0.641891,
                  0.534002,
                  0.426963,
                  0.32371,
                  0.234284,
                  0.163972,
                  0.110211,
                  0.072478,
                  0.046194,
                  0.029401,
                  0.019359,
                  0.013308,
                  0.009317,
                  0.006523,
                  0.004864,
                  0.003409,
                  0.002491,
                  0.001958,
                  0.001423,
                  0.001055,
                  0.000498,
                  0.000228,
                  0.000159,
                  3.4e-05,
                  4.5e-05,
                  1.3e-05],
     'wavelength': [1539,
                    1540,
                    1541,
                    1542,
                    1543,
                    1544,
                    1545,
                    1546,
                    1547,
                    1548,
                    1549,
                    1550,
                    1551,
                    1552,
                    1553,
                    1554,
                    1555,
                    1556,
                    1557,
                    1558,
                    1559,
                    1560,
                    1561,
                    1562,
                    1563,
                    1564,
                    1565,
                    1566,
                    1567,
                    1568,
                    1569,
                    1570,
                    1571,
                    1572,
                    1573,
                    1574,
                    1575,
                    1576,
                    1577,
                    1578,
                    1579,
                    1580,
                    1581,
                    1582,
                    1583,
                    1584,
                    1585,
                    1586,
                    1587,
                    1588,
                    1589,
                    1590,
                    1591,
                    1592,
                    1593,
                    1594,
                    1595,
                    1596,
                    1597,
                    1598,
                    1599,
                    1600,
                    1601,
                    1602,
                    1603,
                    1604,
                    1605,
                    1606,
                    1607,
                    1608,
                    1609,
                    1610,
                    1611,
                    1612,
                    1613,
                    1614,
                    1615,
                    1616,
                    1617,
                    1618,
                    1619,
                    1620,
                    1621,
                    1622,
                    1623,
                    1624,
                    1625,
                    1626,
                    1627,
                    1628,
                    1629,
                    1630,
                    1631,
                    1632,
                    1633,
                    1634,
                    1635,
                    1636,
                    1637,
                    1638,
                    1639,
                    1640,
                    1641,
                    1642,
                    1643,
                    1644,
                    1645,
                    1646,
                    1647,
                    1648,
                    1649,
                    1650,
                    1651,
                    1652,
                    1653,
                    1654,
                    1655,
                    1656,
                    1657,
                    1658,
                    1659,
                    1660,
                    1661,
                    1662,
                    1663,
                    1664,
                    1665,
                    1666,
                    1667,
                    1668,
                    1669,
                    1670,
                    1671,
                    1672,
                    1673,
                    1674,
                    1675,
                    1676,
                    1677,
                    1678,
                    1679,
                    1680,
                    1681,
                    1682]}

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/odcadmin/miniconda3/envs/odc/lib/python3.9/site-packages/datacube/scripts/product.py", line 55, in add_products
    type_ = index.products.from_doc(parsed_doc)
  File "/home/odcadmin/miniconda3/envs/odc/lib/python3.9/site-packages/datacube/index/_products.py", line 56, in from_doc
    DatasetType.validate(definition)
  File "/home/odcadmin/miniconda3/envs/odc/lib/python3.9/site-packages/datacube/utils/documents.py", line 489, in validate
    return validate_document(document, cls.schema, schema.parent)
  File "/home/odcadmin/miniconda3/envs/odc/lib/python3.9/site-packages/datacube/utils/documents.py", line 221, in validate_document
    raise InvalidDocException(e)
datacube.utils.documents.InvalidDocException: {'response': ['7e-06', '7e-06', '8e-06', 2.8e-05, 3.8e-05, 9.1e-05, 0.000147, 0.000251, 0.00048, 0.00057, 0.000662, 0.000911, 0.001166, 0.001684, 0.002458, 0.003567, 0.005345, 0.008318, 0.012628, 0.018996, 0.027781, 0.039584, 0.054865, 0.07493, 0.10107, 0.135476, 0.182597, 0.247276, 0.330736, 0.429691, 0.537634, 0.647173, 0.743528, 0.815215, 0.859202, 0.879669, 0.88703, 0.889098, 0.891417, 0.897586, 0.906631, 0.916528, 0.926579, 0.935322, 0.942394, 0.947507, 0.951416, 0.954254, 0.956429, 0.958205, 0.960688, 0.96348, 0.965797, 0.96818, 0.971012, 0.97338, 0.975915, 0.978581, 0.979878, 0.980589, 0.980912, 0.981412, 0.981244, 0.980705, 0.980377, 0.981066, 0.982736, 0.985122, 0.987807, 0.990376, 0.992016, 0.993288, 0.992536, 0.990405, 0.987128, 0.983502, 0.980023, 0.976174, 0.972568, 0.969828, 0.967709, 0.966371, 0.965849, 0.96605, 0.967427, 0.96987, 0.973463, 0.978683, 0.983472, 0.987635, 0.991875, 0.995476, 0.997586, 0.998568, 0.999328, 0.999234, 0.998804, 0.999111, 0.99973, 0.999745, 1.0, 0.999814, 0.996693, 0.99162, 0.985702, 0.978569, 0.969903, 0.960896, 0.953287, 0.946546, 0.941712, 0.938586, 0.935489, 0.928114, 0.912102, 0.880598, 0.82498, 0.743118, 0.641891, 0.534002, 0.426963, 0.32371, 0.234284, 0.163972, 0.110211, 0.072478, 0.046194, 0.029401, 0.019359, 0.013308, 0.009317, 0.006523, 0.004864, 0.003409, 0.002491, 0.001958, 0.001423, 0.001055, 0.000498, 0.000228, 0.000159, 3.4e-05, 4.5e-05, 1.3e-05], 'wavelength': [1539, 1540, 1541, 1542, 1543, 1544, 1545, 1546, 1547, 1548, 1549, 1550, 1551, 1552, 1553, 1554, 1555, 1556, 1557, 1558, 1559, 1560, 1561, 1562, 1563, 1564, 1565, 1566, 1567, 1568, 1569, 1570, 1571, 1572, 1573, 1574, 1575, 1576, 1577, 1578, 1579, 1580, 1581, 1582, 1583, 1584, 1585, 1586, 1587, 1588, 1589, 1590, 1591, 1592, 1593, 1594, 1595, 1596, 1597, 1598, 1599, 1600, 1601, 1602, 1603, 1604, 1605, 1606, 1607, 1608, 1609, 1610, 1611, 1612, 1613, 1614, 1615, 1616, 1617, 1618, 1619, 1620, 1621, 1622, 1623, 1624, 1625, 1626, 1627, 1628, 1629, 1630, 1631, 1632, 1633, 1634, 1635, 1636, 1637, 1638, 1639, 1640, 1641, 1642, 1643, 1644, 1645, 1646, 1647, 1648, 1649, 1650, 1651, 1652, 1653, 1654, 1655, 1656, 1657, 1658, 1659, 1660, 1661, 1662, 1663, 1664, 1665, 1666, 1667, 1668, 1669, 1670, 1671, 1672, 1673, 1674, 1675, 1676, 1677, 1678, 1679, 1680, 1681, 1682]} is not valid under any of the given schemas

Failed validating 'oneOf' in schema['properties']['measurements']['items']['properties']['spectral_definition']:
    {'oneOf': [{'$ref': '#/definitions/spectral_definition'},
               {'description': 'List of spectral definitions, one per '
                               'coordinate.',
                'items': {'$ref': '#/definitions/spectral_definition'},
                'type': 'array'}]}

On instance['measurements'][22]['spectral_definition']:
    {'response': ['7e-06',
                  '7e-06',
                  '8e-06',
                  2.8e-05,
                  3.8e-05,
                  9.1e-05,
                  0.000147,
                  0.000251,
                  0.00048,
                  0.00057,
                  0.000662,
                  0.000911,
                  0.001166,
                  0.001684,
                  0.002458,
                  0.003567,
                  0.005345,
                  0.008318,
                  0.012628,
                  0.018996,
                  0.027781,
                  0.039584,
                  0.054865,
                  0.07493,
                  0.10107,
                  0.135476,
                  0.182597,
                  0.247276,
                  0.330736,
                  0.429691,
                  0.537634,
                  0.647173,
                  0.743528,
                  0.815215,
                  0.859202,
                  0.879669,
                  0.88703,
                  0.889098,
                  0.891417,
                  0.897586,
                  0.906631,
                  0.916528,
                  0.926579,
                  0.935322,
                  0.942394,
                  0.947507,
                  0.951416,
                  0.954254,
                  0.956429,
                  0.958205,
                  0.960688,
                  0.96348,
                  0.965797,
                  0.96818,
                  0.971012,
                  0.97338,
                  0.975915,
                  0.978581,
                  0.979878,
                  0.980589,
                  0.980912,
                  0.981412,
                  0.981244,
                  0.980705,
                  0.980377,
                  0.981066,
                  0.982736,
                  0.985122,
                  0.987807,
                  0.990376,
                  0.992016,
                  0.993288,
                  0.992536,
                  0.990405,
                  0.987128,
                  0.983502,
                  0.980023,
                  0.976174,
                  0.972568,
                  0.969828,
                  0.967709,
                  0.966371,
                  0.965849,
                  0.96605,
                  0.967427,
                  0.96987,
                  0.973463,
                  0.978683,
                  0.983472,
                  0.987635,
                  0.991875,
                  0.995476,
                  0.997586,
                  0.998568,
                  0.999328,
                  0.999234,
                  0.998804,
                  0.999111,
                  0.99973,
                  0.999745,
                  1.0,
                  0.999814,
                  0.996693,
                  0.99162,
                  0.985702,
                  0.978569,
                  0.969903,
                  0.960896,
                  0.953287,
                  0.946546,
                  0.941712,
                  0.938586,
                  0.935489,
                  0.928114,
                  0.912102,
                  0.880598,
                  0.82498,
                  0.743118,
                  0.641891,
                  0.534002,
                  0.426963,
                  0.32371,
                  0.234284,
                  0.163972,
                  0.110211,
                  0.072478,
                  0.046194,
                  0.029401,
                  0.019359,
                  0.013308,
                  0.009317,
                  0.006523,
                  0.004864,
                  0.003409,
                  0.002491,
                  0.001958,
                  0.001423,
                  0.001055,
                  0.000498,
                  0.000228,
                  0.000159,
                  3.4e-05,
                  4.5e-05,
                  1.3e-05],
     'wavelength': [1539,
                    1540,
                    1541,
                    1542,
                    1543,
                    1544,
                    1545,
                    1546,
                    1547,
                    1548,
                    1549,
                    1550,
                    1551,
                    1552,
                    1553,
                    1554,
                    1555,
                    1556,
                    1557,
                    1558,
                    1559,
                    1560,
                    1561,
                    1562,
                    1563,
                    1564,
                    1565,
                    1566,
                    1567,
                    1568,
                    1569,
                    1570,
                    1571,
                    1572,
                    1573,
                    1574,
                    1575,
                    1576,
                    1577,
                    1578,
                    1579,
                    1580,
                    1581,
                    1582,
                    1583,
                    1584,
                    1585,
                    1586,
                    1587,
                    1588,
                    1589,
                    1590,
                    1591,
                    1592,
                    1593,
                    1594,
                    1595,
                    1596,
                    1597,
                    1598,
                    1599,
                    1600,
                    1601,
                    1602,
                    1603,
                    1604,
                    1605,
                    1606,
                    1607,
                    1608,
                    1609,
                    1610,
                    1611,
                    1612,
                    1613,
                    1614,
                    1615,
                    1616,
                    1617,
                    1618,
                    1619,
                    1620,
                    1621,
                    1622,
                    1623,
                    1624,
                    1625,
                    1626,
                    1627,
                    1628,
                    1629,
                    1630,
                    1631,
                    1632,
                    1633,
                    1634,
                    1635,
                    1636,
                    1637,
                    1638,
                    1639,
                    1640,
                    1641,
                    1642,
                    1643,
                    1644,
                    1645,
                    1646,
                    1647,
                    1648,
                    1649,
                    1650,
                    1651,
                    1652,
                    1653,
                    1654,
                    1655,
                    1656,
                    1657,
                    1658,
                    1659,
                    1660,
                    1661,
                    1662,
                    1663,
                    1664,
                    1665,
                    1666,
                    1667,
                    1668,
                    1669,
                    1670,
                    1671,
                    1672,
                    1673,
                    1674,
                    1675,
                    1676,
                    1677,
                    1678,
                    1679,
                    1680,
                    1681,
                    1682]}
2022-06-29 11:37:22,144 409694 datacube-product ERROR Invalid product definition: s2a_ard_granule.odc-product.yaml
(odc) [odcadmin@odc-app01p tmp]$
```


### Steps to reproduce the behaviour

```
datacube product add https://explorer.sandbox.dea.ga.gov.au/products/s2a_ard_granule.odc-product.yaml
```



Discussion:

Resolving patch:
diff --git a/datacube/scripts/metadata.py b/datacube/scripts/metadata.py
--- a/datacube/scripts/metadata.py
+++ b/datacube/scripts/metadata.py
@@ -14,7 +14,7 @@
 
 from datacube.index import Index
 from datacube.ui import click as ui
-from datacube.ui.click import cli, print_help_msg
+from datacube.ui.click import cli, print_help_msg, exit_on_empty_file
 from datacube.utils import read_documents, InvalidDocException
 from datacube.utils.serialise import SafeDatacubeDumper
 
@@ -42,6 +42,8 @@ def add_metadata_types(index, allow_exclusive_lock, files):
         print_help_msg(add_metadata_types)
         sys.exit(1)
 
+    exit_on_empty_file(list(read_documents(*files)))
+
     for descriptor_path, parsed_doc in read_documents(*files):
         try:
             type_ = index.metadata_types.from_doc(parsed_doc)
@@ -76,6 +78,8 @@ def update_metadata_types(index: Index, allow_unsafe: bool, allow_exclusive_lock
         print_help_msg(update_metadata_types)
         sys.exit(1)
 
+    exit_on_empty_file(list(read_documents(*files)))
+
     for descriptor_path, parsed_doc in read_documents(*files):
         try:
             type_ = index.metadata_types.from_doc(parsed_doc)
diff --git a/datacube/scripts/product.py b/datacube/scripts/product.py
--- a/datacube/scripts/product.py
+++ b/datacube/scripts/product.py
@@ -17,7 +17,7 @@
 
 from datacube.index import Index
 from datacube.ui import click as ui
-from datacube.ui.click import cli, print_help_msg
+from datacube.ui.click import cli, print_help_msg, exit_on_empty_file
 from datacube.utils import read_documents, InvalidDocException
 from datacube.utils.serialise import SafeDatacubeDumper
 
@@ -53,6 +53,8 @@ def on_ctrlc(sig, frame):
 
     signal.signal(signal.SIGINT, on_ctrlc)
 
+    exit_on_empty_file(list(read_documents(*files)))
+
     for descriptor_path, parsed_doc in read_documents(*files):
         try:
             type_ = index.products.from_doc(parsed_doc)
@@ -89,6 +91,8 @@ def update_products(index: Index, allow_unsafe: bool, allow_exclusive_lock: bool
         print_help_msg(update_products)
         sys.exit(1)
 
+    exit_on_empty_file(list(read_documents(*files)))
+
     failures = 0
     for descriptor_path, parsed_doc in read_documents(*files):
         try:
diff --git a/datacube/ui/click.py b/datacube/ui/click.py
--- a/datacube/ui/click.py
+++ b/datacube/ui/click.py
@@ -365,3 +365,9 @@ def my_parse(ctx, param, value):
 def print_help_msg(command):
     with click.Context(command) as ctx:
         click.echo(command.get_help(ctx))
+
+
+def exit_on_empty_file(read_files_list):
+    if len(read_files_list) == 0:
+        click.echo("All files are empty, exit")
+        sys.exit(1)


Test patch:
diff --git a/integration_tests/conftest.py b/integration_tests/conftest.py
--- a/integration_tests/conftest.py
+++ b/integration_tests/conftest.py
@@ -539,4 +539,5 @@ def dataset_add_configs():
                            datasets_bad1=str(B / 'datasets_bad1.yml'),
                            datasets_no_id=str(B / 'datasets_no_id.yml'),
                            datasets_eo3=str(B / 'datasets_eo3.yml'),
-                           datasets=str(B / 'datasets.yml'))
+                           datasets=str(B / 'datasets.yml'),
+                           empty_file=str(B / 'empty_file.yml'))
diff --git a/integration_tests/data/dataset_add/empty_file.yml b/integration_tests/data/dataset_add/empty_file.yml
new file mode 100644
diff --git a/integration_tests/test_cli_output.py b/integration_tests/test_cli_output.py
--- a/integration_tests/test_cli_output.py
+++ b/integration_tests/test_cli_output.py
@@ -1,26 +1,42 @@
-def test_cli_product_subcommand(index_empty, clirunner):
+def test_cli_product_subcommand(index_empty, clirunner, dataset_add_configs):
     runner = clirunner(['product', 'update'], verbose_flag=False, expect_success=False)
     assert "Usage:  [OPTIONS] [FILES]" in runner.output
     assert "Update existing products." in runner.output
     assert runner.exit_code == 1
 
+    runner = clirunner(['product', 'update', dataset_add_configs.empty_file], verbose_flag=False, expect_success=False)
+    assert "All files are empty, exit" in runner.output
+    assert runner.exit_code == 1
+
     runner = clirunner(['product', 'add'], verbose_flag=False, expect_success=False)
     assert "Usage:  [OPTIONS] [FILES]" in runner.output
     assert "Add or update products in" in runner.output
     assert runner.exit_code == 1
 
+    runner = clirunner(['product', 'add', dataset_add_configs.empty_file], verbose_flag=False, expect_success=False)
+    assert "All files are empty, exit" in runner.output
+    assert runner.exit_code == 1
+
 
-def test_cli_metadata_subcommand(index_empty, clirunner):
+def test_cli_metadata_subcommand(index_empty, clirunner, dataset_add_configs):
     runner = clirunner(['metadata', 'update'], verbose_flag=False, expect_success=False)
     assert "Usage:  [OPTIONS] [FILES]" in runner.output
     assert "Update existing metadata types." in runner.output
     assert runner.exit_code == 1
 
+    runner = clirunner(['metadata', 'update', dataset_add_configs.empty_file], verbose_flag=False, expect_success=False)
+    assert "All files are empty, exit" in runner.output
+    assert runner.exit_code == 1
+
     runner = clirunner(['metadata', 'add'], verbose_flag=False, expect_success=False)
     assert "Usage:  [OPTIONS] [FILES]" in runner.output
     assert "Add or update metadata types in" in runner.output
     assert runner.exit_code == 1
 
+    runner = clirunner(['metadata', 'add', dataset_add_configs.empty_file], verbose_flag=False, expect_success=False)
+    assert "All files are empty, exit" in runner.output
+    assert runner.exit_code == 1
+
 
 def test_cli_dataset_subcommand(index_empty, clirunner, dataset_add_configs):
     clirunner(['metadata', 'add', dataset_add_configs.metadata])