ls1intum / Apollon

UML Modeling Editor written in React
https://apollon-library.readthedocs.io
MIT License
65 stars 22 forks source link

fix an issue with transforming corrupted models from v2 #316

Closed loreanvictor closed 10 months ago

loreanvictor commented 10 months ago

Checklist

Motivation and Context

I was working on integrating Apollon v3 with Artemis, and realised that sometimes v2 models are stored with the wrong format, which causes errors when Apollon 3 tries to load them and convert them to v3 schema.

Description

It can happen that v2 models are stored with the wrong format / typing, which will cause errors to be thrown by the backwards compatibility code that tries to convert the corrupt v2 model to v3. For example, essential fields of the model might be absent (e.g. elements, assessments, etc) or of the wrong type (e.g. an empty object instead of an array).

Steps for Testing

Basically create a corrupted JSON diagram.

  1. Run locally (npm start)
  2. Create and save the diagram
  3. Corrupt the diagram: open developer console on browser and type the following:
    localStorage.setItem('apollon', "{\"version\": \"2.0.0\"\}")
  4. Reload the page, you'll see an error thrown in the console due to the corrupt model.

Test Coverage

File Branch Line
main/compat/v2/transform.ts 100% 100%