OpenEnergyPlatform / oeplatform

Repository for the code of the Open Energy Platform (OEP) website. The OEP provides an interface to the Open Energy Family
http://openenergyplatform.org/
GNU Affero General Public License v3.0
62 stars 19 forks source link

The scenario bundles raise http 500 if there is some unexpectet text added to the OEKG nodes. #1794

Closed jh-RLI closed 2 months ago

jh-RLI commented 3 months ago

Description of the issue

An error has occurred in one of the recently added scenario bundles. The overview page of the scenario bundles cannot currently be accessed.

This bundle OEKG-URI: http://openenergy-platform.org/ontology/oekg/0bbb21b8-d233-2963-7976-aa18ce8b0382

holds this abstract:

Europe’s contribution to global warming will be determined by the cumulative emissions until climate neutrality is achieved. Here, we investigate alternative transition paths under different carbon budgets. We use PyPSA-Eur-Sec, an open model of the sector-coupled European energy system with high spatial and temporal resolution. All the paths entail similar technological transformations, but the timing of the scale-up of important technologies like electrolysis, carbon capture, and hydrogen network differs. Solar PV and onshore and offshore wind become the cornerstone of a net-zero energy system, enabling the decarbonization of other sectors via direct electrification (heat pumps and electric vehicles) or indirect electrification (using synthetic fuels). For a social cost of carbon (SCC) of 120V/tCO2, transition paths under 1.5 and 1.6C budgets are, respectively, 8% and 1% more expensive than the 2C budget because building assets earlier costs more. The 1.5C budget is cost optimal if a SCC of at least 300V/tCO2 is considered.

leading to this exception:

  File "/usr/lib/python3.10/xml/etree/ElementTree.py", line 586, in parse
    parser.feed(data)
xml.etree.ElementTree.ParseError: not well-formed (invalid token): line 9, column 864

Steps to Reproduce

  1. Navigate to the scenario bundles page

Reproduce the root cause

  1. create a scenario bundle
  2. insert incompatible characters in one of the input fields, e.g. in the ‘Abstract’ text field
  3. send

Ideas of solution

The specific symbol 1.5C includes a non-printable character (the  symbol, which is a "Start of Heading" control character). This kind of character is not valid in XML documents and would cause a parsing error if it appears within the XML content.

To fix the current error we must update the node here: image

To prevent this problem from occurring again, we need to validate the user input and ensure that there is no invalid XML content. Otherwise, we need to work around the problem.

Context and Environment

Workflow checklist

jh-RLI commented 2 months ago

We have now also manually corrected the incorrect data in the oekg - this has fixed the issue. The code has been updated to prevent the problem from recurring.