Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
sidemt opened this issue Oct 18, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@sidemt
Copy link

sidemt commented Oct 18, 2023

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:

  • Run npx create-strapi-app@latest config-sync-test --quickstart
  • Install config-sync
  • Set up test environment according to: https://docs.strapi.io/dev-docs/testing
  • Set importOnBootstrap: true in config/env/test/plugins.js

System

  • Node.js version: v18.16.0
  • NPM version: 9.5.1
  • Strapi version: 4.14.4
  • Plugin version: 1.2.1
  • Database: better-sqlite3 v8.6.0
  • Operating system: Ubuntu 20.04.6 LTS (WSL2)

Additional context

Add any other context about the problem here.

@boazpoolman
Copy link
Member

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

@boazpoolman boazpoolman removed the Needs investigation Further information is requested label Oct 19, 2023
@MSACC
Copy link
Collaborator

MSACC commented Oct 21, 2023

Fixed in #111

@MSACC MSACC closed this as completed Oct 21, 2023
@boazpoolman
Copy link
Member

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

@boazpoolman boazpoolman reopened this Oct 23, 2023
@sidemt
Copy link
Author

sidemt commented Oct 23, 2023

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

@boazpoolman
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants