tractr / directus-sync

A CLI tool for synchronizing the schema and configuration of Directus across various environments.
GNU General Public License v3.0
209 stars 8 forks source link

Providing a wrong path to a config file gives misleading error output #80

Closed almereyda closed 1 day ago

almereyda commented 3 months ago

Describe the bug

When running the command with a parameter for a configuration file that doesn't exist, the resulting error indicates something wrong within the file, but does not highlight the fact, that it wasn't found in the first place.

To Reproduce Steps to reproduce the behavior:

$ npx directus-sync -c directus-sync.nightly.cjs diff
[16:19:44.185] ERROR (342257): Options parsing: [directusUrl] Required
    err: {
      "type": "Error",
      "message": "Options parsing: [directusUrl] Required",
      "stack":
          Error: Options parsing: [directusUrl] Required
              at zodParse (/home/yala/src/lab.allmende.io/ecobytes/web/node_modules/.pnpm/directus-sync@2.1.0/node_modules/directus-sync/dist/lib/helpers.js:73:15)
              at ConfigService.flattenOptions (/home/yala/src/lab.allmende.io/ecobytes/web/node_modules/.pnpm/directus-sync@2.1.0/node_modules/directus-sync/dist/lib/services/config/config.js:145:39)
              at ConfigService.cacheOriginalMethod (/home/yala/src/lab.allmende.io/ecobytes/web/node_modules/.pnpm/typescript-cacheable@3.0.3/node_modules/typescript-cacheable/dist/Cacheable.js:107:53)
              at ConfigService.<anonymous> (/home/yala/src/lab.allmende.io/ecobytes/web/node_modules/.pnpm/typescript-cacheable@3.0.3/node_modules/typescript-cacheable/dist/Cacheable.js:97:36)
              at ConfigService.getOptions (/home/yala/src/lab.allmende.io/ecobytes/web/node_modules/.pnpm/directus-sync@2.1.0/node_modules/directus-sync/dist/lib/services/config/config.js:120:30)
              at ConfigService.requireOptions (/home/yala/src/lab.allmende.io/ecobytes/web/node_modules/.pnpm/directus-sync@2.1.0/node_modules/directus-sync/dist/lib/services/config/config.js:124:28)
              at ConfigService.getLoggerConfig (/home/yala/src/lab.allmende.io/ecobytes/web/node_modules/.pnpm/directus-sync@2.1.0/node_modules/directus-sync/dist/lib/services/config/config.js:31:25)
              at ConfigService.cacheOriginalMethod (/home/yala/src/lab.allmende.io/ecobytes/web/node_modules/.pnpm/typescript-cacheable@3.0.3/node_modules/typescript-cacheable/dist/Cacheable.js:107:53)
              at ConfigService.<anonymous> (/home/yala/src/lab.allmende.io/ecobytes/web/node_modules/.pnpm/typescript-cacheable@3.0.3/node_modules/typescript-cacheable/dist/Cacheable.js:97:36)
              at /home/yala/src/lab.allmende.io/ecobytes/web/node_modules/.pnpm/directus-sync@2.1.0/node_modules/directus-sync/dist/lib/loader.js:36:27
    }

This was caused by the configuration file actually being called directus-sync.nightly.json, within which no syntax errors could be found..

Expected behavior

The command gives a clear and concise description of what caused it, stating that the file does not exist.

Versions (please complete the following information):

EdouardDem commented 2 months ago

@almereyda This is done on purpose to avoid warning when the default path directus-sync.config.js does not exists. However, we could trigger a warning when the path is not the default one and the file does not exists.

almereyda commented 2 months ago

Yes, a wrong layer in the cascade of errors is surfaced.

almereyda commented 3 weeks ago

The same error appeared today, but when running through npm instead of npx. Yet another failure condition triggered this, since a configuration file would not be found, which an npx invocation was perfectly fine with.

EdouardDem commented 1 day ago

This has been solved : https://github.com/tractr/directus-sync/releases/tag/directus-sync%403.1.2

almereyda commented 7 hours ago

Arigato.