freeCodeCamp / publish

> Content backend platform for /news
https://publish.freecodecamp.org
BSD 3-Clause "New" or "Revised" License
10 stars 9 forks source link

Error when saving a post without feature image #372

Closed sidemt closed 8 months ago

sidemt commented 10 months ago

*In addition to fixing this error, we will need to change the content type to have 1 single feature image: #370

Describe the bug Backend log (I added console.error(err) in catch block in controller to see this log)

backend:develop: YupValidationError: Invalid relations
backend:develop:     at handleYupError (/home/sidemt/workspace/fcc/publish/node_modules/@strapi/utils/dist/index.js:408:9)
backend:develop:     at /home/sidemt/workspace/fcc/publish/node_modules/@strapi/utils/dist/index.js:418:7
backend:develop:     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
backend:develop:     at async Object.update (/home/sidemt/workspace/fcc/publish/node_modules/@strapi/strapi/dist/services/entity-service/index.js:156:23)
backend:develop:     at async Object.<anonymous> (/home/sidemt/workspace/fcc/publish/node_modules/@strapi/strapi/dist/services/entity-service/index.js:309:18)
backend:develop:     at async Object.update (/home/sidemt/workspace/fcc/publish/node_modules/@strapi/plugin-i18n/server/services/entity-service-decorator.js:155:19)
backend:develop:     at async Object.update (/home/sidemt/workspace/fcc/publish/node_modules/@strapi/strapi/dist/core-api/controller/collection-type.js:68:22)
backend:develop:     at async Object.update (/home/sidemt/workspace/fcc/publish/apps/backend/src/api/post/controllers/post.js:93:16)
backend:develop:     at async returnBodyMiddleware (/home/sidemt/workspace/fcc/publish/node_modules/@strapi/strapi/dist/services/server/compose-endpoint.js:42:18)
backend:develop:     at async policiesMiddleware (/home/sidemt/workspace/fcc/publish/node_modules/@strapi/strapi/dist/services/server/policy.js:15:5) {
backend:develop:   details: { errors: [ [Object] ] }
backend:develop: }

It says 403 in the response body above but the HTTP status code of the response was 400: (Edited: I was just confused by the developer tool... forget about it) image

To Reproduce Steps to reproduce the behavior:

  1. Go to http://localhost:3000/posts
  2. Click on "New Post"
  3. Save the post without adding a feature image

Expected behavior The post should be saved successfully

Screenshots image

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.