ZINC-FYP-2022-23 / console

ZINC UI for teaching assistants
1 stars 0 forks source link

fix(gui): extra space in front of YAML key name causes page crash #46

Closed AnsonH closed 1 year ago

AnsonH commented 1 year ago

Description

  1. Visit YAML Editor mode and add a space in front of the first key name (i.e. _settings) in the YAML:
    - _settings:
    +  _settings:
     lang: cpp/g++:8
     # ...
    fileStructureValidation:
     # ...
  2. Visit the GUI Mode
  3. The page crashes with the following error:
YAMLException: end of the stream or a document separator is expected at line 12, column 1:
    fileStructureValidation:
    ^
    at E (https://zinc2023.ust.dev/_next/static/chunks/3725-a2c586579e2561d8.js:1:139122)
    at I (https://zinc2023.ust.dev/_next/static/chunks/3725-a2c586579e2561d8.js:1:139220)
    at $ (https://zinc2023.ust.dev/_next/static/chunks/3725-a2c586579e2561d8.js:1:153042)
    at L (https://zinc2023.ust.dev/_next/static/chunks/3725-a2c586579e2561d8.js:1:153479)
    at q (https://zinc2023.ust.dev/_next/static/chunks/3725-a2c586579e2561d8.js:1:153698)
    at C (https://zinc2023.ust.dev/_next/static/chunks/6972-58787b9c407b1dfb.js:1:32370)
    at https://zinc2023.ust.dev/_next/static/chunks/6972-58787b9c407b1dfb.js:1:16122
    at https://zinc2023.ust.dev/_next/static/chunks/3725-a2c586579e2561d8.js:1:114862
    at https://zinc2023.ust.dev/_next/static/chunks/3725-a2c586579e2561d8.js:1:114201
    at https://zinc2023.ust.dev/_next/static/chunks/3725-a2c586579e2561d8.js:1:114836

Solution

Try trimLeft() on the YAML config in the Monaco Editor before saving to the database.