pluginpal / strapi-plugin-config-sync

:recycle: CLI & GUI for continuous migration of config data across environments
https://www.pluginpal.io/plugin/config-sync
MIT License
255 stars 37 forks source link

`ValidationError: Invalid relations` when importOnBootstrap enabled (since v1.2.0) #109

Closed sidemt closed 1 year ago

sidemt commented 1 year ago

Bug report

Describe the bug

I'm using this plugin for setting up the test environment. But since v1.2.0 it started failing to import config with ValidationError: Invalid relations.

I can only reproduce this error when I import config with importOnBootstrap: true. If I use yarn cs import or npm run cs import manually, it works.

Steps to reproduce the behavior

  1. Clone this repository
  2. run yarn install
  3. run yarn test
  4. See error ValidationError: Invalid relations

Error log:

$ yarn test
yarn run v1.22.19
$ jest --forceExit --detectOpenHandles
jest-haste-map: duplicate manual mock found: index
  The following files share their name; please delete one of them:
    * <rootDir>/.cache/admin/src/hooks/useAdminRolePermissions/__mocks__/index.js
    * <rootDir>/.cache/admin/src/hooks/useAdminRoles/__mocks__/index.js

jest-haste-map: duplicate manual mock found: index
  The following files share their name; please delete one of them:
    * <rootDir>/.cache/admin/src/hooks/useAdminRoles/__mocks__/index.js
    * <rootDir>/.cache/admin/src/hooks/useAdminUsers/__mocks__/index.js

jest-haste-map: duplicate manual mock found: index
  The following files share their name; please delete one of them:
    * <rootDir>/.cache/admin/src/hooks/useAdminUsers/__mocks__/index.js
    * <rootDir>/.cache/admin/src/hooks/useContentTypes/__mocks__/index.js

 FAIL  tests/app.test.js (7.376 s)
  ✕ strapi is defined

  ● strapi is defined

    Error when trying to import core-store.core_admin_auth. ValidationError: Invalid relations

       6 | async function setupStrapi() {
       7 |   if (!instance) {
    >  8 |     await Strapi().load();
         |     ^
       9 |     instance = strapi;
      10 |
      11 |     await instance.server.mount();

      at Object.importSingleConfig (node_modules/strapi-plugin-config-sync/server/services/main.js:233:13)
      at node_modules/strapi-plugin-config-sync/server/services/main.js:183:7
          at async Promise.all (index 3)
      at Object.importAllConfig (node_modules/strapi-plugin-config-sync/server/services/main.js:175:5)
      at Object.<anonymous>.module.exports [as bootstrap] (node_modules/strapi-plugin-config-sync/server/bootstrap.js:54:7)
      at Object.bootstrap (node_modules/@strapi/strapi/src/core/domain/module/index.ts:81:7)
      at Object.bootstrap (node_modules/@strapi/strapi/src/core/registries/modules.ts:29:9)
      at Strapi.runLifecyclesFunctions (node_modules/@strapi/strapi/src/Strapi.ts:639:5)
      at Strapi.bootstrap (node_modules/@strapi/strapi/src/Strapi.ts:610:5)
      at Strapi.load (node_modules/@strapi/strapi/src/Strapi.ts:619:5)
      at setupStrapi (tests/helpers/strapi.js:8:5)
      at Object.<anonymous> (tests/app.test.js:5:3)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        7.436 s, estimated 8 s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Expected behavior

Can import config and run tests successfully.

Screenshots

image

Code snippets

Minimal code that can reproduce this issue It's created with the following steps:

System

Additional context

Add any other context about the problem here.

boazpoolman commented 1 year ago

Hi @sidemt, Thanks submitting this issue and providing an example repo. That proved to be very helpfull.

I've been able to replicate this issue and directly wrote an extra integration test for the importOnBootsrap feature. By doing that I've been able to reproduce this issue in a failed pipeline. And I was able to confirm the fix by observing the successful pipeline. This will hopefully prevent this issue from going unnoticed in the future.

The fix is included in the PR #111 Could you test that on your side? You can simply install the PR like so:

yarn add boazpoolman/strapi-plugin-config-sync#pull/111/head
MSACC commented 1 year ago

Fixed in https://github.com/boazpoolman/strapi-plugin-config-sync/pull/111

boazpoolman commented 1 year ago

Re-opened. Can be closed as soon as it's been released.

sidemt commented 1 year ago

@boazpoolman Thank you for the fix. It worked on my side too.

boazpoolman commented 1 year ago

The fix has been released with v1.2.2

If you're still having this, or any other issue with the plugin beyond v1.2.2 please feel free to open a new issue.