directus-sync icon indicating copy to clipboard operation
directus-sync copied to clipboard

Providing a config file gives misleading error output.

Open almereyda opened this issue 1 year ago • 2 comments

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/[email protected]/node_modules/directus-sync/dist/lib/helpers.js:73:15)
              at ConfigService.flattenOptions (/home/yala/src/lab.allmende.io/ecobytes/web/node_modules/.pnpm/[email protected]/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/[email protected]/node_modules/typescript-cacheable/dist/Cacheable.js:107:53)
              at ConfigService.<anonymous> (/home/yala/src/lab.allmende.io/ecobytes/web/node_modules/.pnpm/[email protected]/node_modules/typescript-cacheable/dist/Cacheable.js:97:36)
              at ConfigService.getOptions (/home/yala/src/lab.allmende.io/ecobytes/web/node_modules/.pnpm/[email protected]/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/[email protected]/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/[email protected]/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/[email protected]/node_modules/typescript-cacheable/dist/Cacheable.js:107:53)
              at ConfigService.<anonymous> (/home/yala/src/lab.allmende.io/ecobytes/web/node_modules/.pnpm/[email protected]/node_modules/typescript-cacheable/dist/Cacheable.js:97:36)
              at /home/yala/src/lab.allmende.io/ecobytes/web/node_modules/.pnpm/[email protected]/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):

  • Directus-Sync version: pnpx directus-sync -V outputs error
  • Directus version: v10.x
  • Directus environment Docker Compose

almereyda avatar Jun 16 '24 14:06 almereyda

@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.

EdouardDem avatar Jun 27 '24 09:06 EdouardDem

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

almereyda avatar Jun 27 '24 11:06 almereyda

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.

almereyda avatar Aug 23 '24 14:08 almereyda

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

EdouardDem avatar Sep 13 '24 18:09 EdouardDem

Arigato.

almereyda avatar Sep 14 '24 22:09 almereyda