Skip to content

XMLParseError: KeyError: 'BS_REP_SECTOR' when parsing ECB constraints #240

@zymon

Description

@zymon

import pandasdmx as sdmx
client = sdmx.Request('ECB')
client.contentconstraint('BSI_CONSTRAINTS')

Output:
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): sdw-wsrest.ecb.europa.eu:443
DEBUG:urllib3.connectionpool:https://sdw-wsrest.ecb.europa.eu:443 "GET /service/contentconstraint/ECB/BSI_CONSTRAINTS/latest HTTP/1.1" 200 None

--- SS without DSD ---
{1: False}

--- <class 'pandasdmx.message.StructureMessage'> ---
{2: <pandasdmx.StructureMessage>

id: 'IREF970034' prepared: '2023-03-07T13:50:06+00:00' receiver: sender: source: test: False}

--- Name ---
{8: ('en', 'Constraints for the BSI dataflow.')}

--- <class 'pandasdmx.reader.sdmxml.Reference'> ---
{'BSI': <pandasdmx.reader.sdmxml.Reference object at 0x0000018C13015150>}

--- Value ---
{10: 'P', 11: 'A', 12: 'R', 13: 'B', 14: 'C', 15: 'E', 16: 'U', 17: 'V', 18: 'F', 19: 'L', 20: 'N'}

--- <class 'pandasdmx.model.DataflowDefinition'> ---
{'BSI': <DataflowDefinition ECB:BSI(1.0)>}

<com:KeyValue xmlns:com="http://www.sdmx.org/resources/sdmxml/schemas/v2_1/common" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mes="http://www.sdmx.org/resources/sdmxml/schemas/v2_1/message" xmlns:str="http://www.sdmx.org/resources/sdmxml/schemas/v2_1/structure" id="BS_REP_SECTOR">
com:Value/
com:Value/
com:Value/
com:Value/
com:Value/
com:Value/
com:Value/
com:Value/
com:Value/
com:Value/
com:Value/
</com:KeyValue>

Traceback (most recent call last):
File "r:\SharedLocal\Workplace\2023\03\pandasSdmx_test.venv\Lib\site-packages\pandasdmx\reader\sdmxml.py", line 299, in read_message
result = func(self, element)
^^^^^^^^^^^^^^^^^^^
File "r:\SharedLocal\Workplace\2023\03\pandasSdmx_test.venv\Lib\site-packages\pandasdmx\reader\sdmxml.py", line 1172, in _ms
arg["values_for"] = cl.get(elem.attrib["id"])
^^^^^^^^^^^^^^^^^^^^^^^^^
File "r:\SharedLocal\Workplace\2023\03\pandasSdmx_test.venv\Lib\site-packages\pandasdmx\model.py", line 883, in get
raise KeyError(id)
KeyError: 'BS_REP_SECTOR'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "", line 1, in
File "r:\SharedLocal\Workplace\2023\03\pandasSdmx_test.venv\Lib\site-packages\pandasdmx\api.py", line 514, in get
msg = reader.read_message(response_content, dsd=kwargs.get("dsd", None))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "r:\SharedLocal\Workplace\2023\03\pandasSdmx_test.venv\Lib\site-packages\pandasdmx\reader\sdmxml.py", line 316, in read_message
raise XMLParseError from exc
pandasdmx.exceptions.XMLParseError: KeyError: 'BS_REP_SECTOR'

This was first discovered in sdmx1: khaeru#114

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions