Lissy93 / dashy

🚀 A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!
https://dashy.to
MIT License
17.55k stars 1.34k forks source link

[BUG] Malformed YAML content produced by "Export Config" #482

Closed octagons closed 2 years ago

octagons commented 2 years ago

Environment

Self-Hosted (Docker)

Version

2.0.2

Describe the problem

When I export the configuration from the "View / Export Config" modal in the config menu on the web interface, the content sent by the application when I click "Download as File" has a leading space (i.e. 0x20) on the first column, first line of the file.

If I try to place this file at public/conf.yml without appropriate inspection (yes, I know), the build will fail because it fails to appropriately parse the section indentations from the YAML configuration.

Additional info

I am deploying Dashy from a custom template saved in Portainer. My compose file is below:

---
version: "3.8"
services:
  dashy:
    container_name: Dashy
    image: lissy93/dashy:latest
    volumes:
      - dashy:/app
    ports:
      - 4000:80
    environment:
      - NODE_ENV=production
    restart: unless-stopped
    healthcheck:
      test: ['CMD', 'node', '/app/services/healthcheck']
      interval: 1m30s
      timeout: 10s
      retries: 3
      start_period: 40s
volumes:
  dashy:
    name: dashy

The linter (i.e. yarn validate-config) produces a decent, but somewhat indirect error:

/app/public # yarn validate-config
yarn run v1.22.5
$ node services/config-validator

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
 Error, unable to validate 'conf.yml' 
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Please ensure that your config file is present, has the correct access rights and is parsable. If this warning persists, it may be an issue with the validator function. Please raise an issue, and include the following stack trace:

Stack Trace for config-validator.js:
 YAMLException: end of the stream or a document separator is expected (40:1)

 37 |   disableUpdateChecks: false
 38 |   disableSmartSort: false
 39 |   enableErrorReporting: false
 40 | pageInfo:
------^
 41 |   title: Dashy
 42 |   description: Welcome to your  ...
    at generateError (/app/node_modules/js-yaml/lib/loader.js:183:10)
    at throwError (/app/node_modules/js-yaml/lib/loader.js:187:9)
    at readDocument (/app/node_modules/js-yaml/lib/loader.js:1645:5)
    at loadDocuments (/app/node_modules/js-yaml/lib/loader.js:1688:5)
    at Object.load (/app/node_modules/js-yaml/lib/loader.js:1714:19)
    at Object.<anonymous> (/app/services/config-validator.js:64:23)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12) {
  reason: 'end of the stream or a document separator is expected',
  mark: {
    name: null,
    buffer: ' appConfig:\n' +
      '  theme: one-dark\n' +
< snip >

Please tick the boxes

Lissy93 commented 2 years ago

This should be fixed now, I've replaced my own JSON to YAML parser with the js-yaml module in #488 (released in V2.0.3)