Unable to save relations after upgrade

System Information
  • Strapi Version: 4.5.6
  • Operating System: Ubuntu
  • Database: Postgres
  • Node Version: 14.21
  • NPM Version: 6.14

Upgrading from 4.3.4 to 4.5.6 has left me unable to save new documents which had relations. I can create / edit blog_posts but relations are not being persisted

The following errors are showing up in the logs:

Error: Invalid id, expected a string or integer, got [object Object]
    at /opt/org/node_modules/@strapi/database/lib/entity-manager.js:25:15
    at Array.map (<anonymous>)
    at toAssocs (/opt/org/node_modules/@strapi/database/lib/entity-manager.js:17:6)
    at Object.updateRelations (/opt/org/node_modules/@strapi/database/lib/entity-manager.js:667:28)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Object.update (/opt/org/node_modules/@strapi/database/lib/entity-manager.js:253:7)
    at async Object.update (/opt/org/node_modules/@strapi/strapi/lib/services/entity-service/index.js:193:18)
    at async Object.<anonymous> (/opt/org/node_modules/@strapi/strapi/lib/services/entity-service/index.js:316:20)
    at async Object.update (/opt/org/node_modules/@strapi/plugin-content-manager/server/controllers/collection-types.js:123:27)
    at async returnBodyMiddleware (/opt/org/node_modules/@strapi/strapi/lib/services/server/compose-endpoint.js:52:18)
TypeError: db.query(...).loadPages is not a function
    at Object.loadPages (/opt/org/node_modules/@strapi/strapi/lib/services/entity-service/index.js:285:26)
    at Object.loadPages (/opt/org/node_modules/@strapi/strapi/lib/services/entity-service/index.js:316:49)
    at proto.<computed> [as loadPages] (/opt/org/node_modules/delegates/index.js:40:31)
    at Object.findExisting (/opt/org/node_modules/@strapi/plugin-content-manager/server/controllers/relations.js:199:46)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async returnBodyMiddleware (/opt/org/node_modules/@strapi/strapi/lib/services/server/compose-endpoint.js:52:18)
    at async policiesMiddleware (/opt/org/node_modules/@strapi/strapi/lib/services/server/policy.js:24:5)
    at async serve (/opt/org/node_modules/koa-static/index.js:59:5)
    at async returnBodyMiddleware (/opt/org/node_modules/@strapi/strapi/lib/services/server/compose-endpoint.js:52:18)
    at async policiesMiddleware (/opt/org/node_modules/@strapi/strapi/lib/services/server/policy.js:24:5)

The migration to v4.5.1 migration mentions running a DB script if the server fails to start, but mine has no issues so I left it, would running the script solve my issue?

For reference, the blog-post document has 2 relations: author and tags listed as follows:

{
  "kind": "collectionType",
  "collectionName": "blog_posts",
  "info": {
    "singularName": "blog-post",
    "pluralName": "blog-posts",
    "displayName": "Blog Post",
    "description": ""
  },
  "options": {
    "draftAndPublish": true
  },
  "pluginOptions": {},
  "attributes": {
    "title": {
      "type": "string",
      "required": true
    },
    "author": {
      "type": "relation",
      "relation": "oneToOne",
      "target": "api::author.author"
    },
    "content": {
      "type": "richtext"
    },
    "visibility": {
      "type": "enumeration",
      "enum": [
        "Everyone",
        "Internal",
        "External"
      ],
      "default": "Everyone",
      "required": true
    },
    "header_image": {
      "type": "media",
      "multiple": false,
      "required": false,
      "allowedTypes": [
        "images"
      ]
    },
    "featured": {
      "type": "boolean",
      "default": false
    },
    "tags": {
      "type": "relation",
      "relation": "oneToMany",
      "target": "api::tag.tag"
    },
    "slug": {
      "type": "uid",
      "targetField": "title"
    },
    "intro": {
      "type": "text",
      "maxLength": 1000
    }
  }
}

The author schema:

{
  "kind": "collectionType",
  "collectionName": "authors",
  "info": {
    "singularName": "author",
    "pluralName": "authors",
    "displayName": "Author",
    "description": ""
  },
  "options": {
    "draftAndPublish": false
  },
  "pluginOptions": {},
  "attributes": {
    "display_name": {
      "type": "string",
      "required": true,
      "unique": false
    },
    "admin_user": {
      "type": "relation",
      "relation": "oneToOne",
      "target": "admin::user"
    },
    "avatar": {
      "type": "string"
    }
  }
}

The tag schema:

{
  "kind": "collectionType",
  "collectionName": "tags",
  "info": {
    "singularName": "tag",
    "pluralName": "tags",
    "displayName": "Tag"
  },
  "options": {
    "draftAndPublish": false
  },
  "pluginOptions": {},
  "attributes": {
    "value": {
      "type": "string",
      "required": true,
      "maxLength": 25,
      "minLength": 2,
      "unique": true,
      "regex": "^[\\w\\s]+$"
    }
  }
}

Did you follow Migrate Guides - Strapi Developer Docs?

4.3.6 → 4.3.8 No - it upgrades sql-lite, I use postgres

4.4.3 → 4.4.5 The migration changes the name of the favicon from favicon.ico to favicon.png . Unrelated to DB

4.4.5 → 4.5.1 If you read my post I ask this very question - the migration is marked as optional if your server does not start. My server starts

Any plugins installed?