Skip to content

Commit 6bfd430

Browse files
authored
Merge pull request #339 from pluginpal/feature/fix-non-existing
Prevent an error when the user tries to update a non-existing entry
2 parents d5d0461 + 36c4a04 commit 6bfd430

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

.changeset/khaki-dragons-love.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"strapi-plugin-webtools": patch
3+
---
4+
5+
fix: prevent an error when the user tries to update a non-existing entry

packages/core/server/middlewares/generate-url-alias.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ const generateUrlAliasMiddleware: Modules.Documents.Middleware.Middleware = asyn
4646
// Fire the action.
4747
const entity = await next() as Modules.Documents.AnyDocument;
4848

49+
// Abort if no entity was created/updated.
50+
if (!entity) {
51+
return entity;
52+
}
53+
4954
// Fetch the full entity.
5055
const fullEntity = await strapi.documents(uid as 'api::test.test').findOne({
5156
documentId: entity.documentId,

0 commit comments

Comments
 (0)