Editing folders broken with non-default folder collection slug
Closed this issue · 3 comments
Describe the Bug
When you change the folder collection slug, e.g. using { folders: { slug: 'folders' } }, editing folders fails with this error:
[18:41:03] ERROR: The collection with slug payload-folders can't be found. Find By ID Operation.
err: {
"type": "APIError",
"message": "The collection with slug payload-folders can't be found. Find By ID Operation.",
"stack":
APIError: The collection with slug payload-folders can't be found. Find By ID Operation.
at findByIDLocal (file:///mnt/c/Users/david/proj/***/node_modules/payload/dist/collections/operations/local/findByID.js:8:15)
at BasePayload.findByID (file:///mnt/c/Users/david/proj/***/node_modules/payload/dist/index.js:138:16)
at file:///mnt/c/Users/david/proj/***/node_modules/payload/dist/folders/hooks/ensureSafeCollectionsChange.js:23:68
at updateDocument (file:///mnt/c/Users/david/proj/***/node_modules/payload/dist/collections/operations/utilities/update.js:93:26)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async updateByIDOperation (file:///mnt/c/Users/david/proj/***/node_modules/payload/dist/collections/operations/updateByID.js:113:22)
at async updateByIDHandler (file:///mnt/c/Users/david/proj/***/node_modules/payload/dist/collections/endpoints/updateByID.js:17:17)
at async handleEndpoints (file:///mnt/c/Users/david/proj/***/node_modules/payload/dist/utilities/handleEndpoints.js:189:26)
at async eval (webpack-internal:///(rsc)/./node_modules/@payloadcms/next/dist/routes/rest/index.js:30:20)
at async AppRouteRouteModule.do (/mnt/c/Users/david/proj/***/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:5:38782)
at async AppRouteRouteModule.handle (/mnt/c/Users/david/proj/***/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:5:45984)
at async responseGenerator (webpack-internal:///(rsc)/./node_modules/next/dist/build/webpack/loaders/next-app-loader/index.js?name=app%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute&page=%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute&appPaths=&pagePath=private-next-app-dir%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute.ts&appDir=%2Fmnt%2Fc%2FUsers%2Fdavid%2Fproj%2F***%2Fsrc%2Fapp&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&rootDir=%2Fmnt%2Fc%2FUsers%2Fdavid%2Fproj%2F***&isDev=true&tsconfigPath=tsconfig.json&basePath=&assetPrefix=&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D&isGlobalNotFoundEnabled=!:206:38)
at async AppRouteRouteModule.handleResponse (/mnt/c/Users/david/proj/***/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:1:183647)
at async handleResponse (webpack-internal:///(rsc)/./node_modules/next/dist/build/webpack/loaders/next-app-loader/index.js?name=app%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute&page=%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute&appPaths=&pagePath=private-next-app-dir%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute.ts&appDir=%2Fmnt%2Fc%2FUsers%2Fdavid%2Fproj%2F***%2Fsrc%2Fapp&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&rootDir=%2Fmnt%2Fc%2FUsers%2Fdavid%2Fproj%2F***&isDev=true&tsconfigPath=tsconfig.json&basePath=&assetPrefix=&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D&isGlobalNotFoundEnabled=!:268:32)
at async handler (webpack-internal:///(rsc)/./node_modules/next/dist/build/webpack/loaders/next-app-loader/index.js?name=app%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute&page=%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute&appPaths=&pagePath=private-next-app-dir%2F(payload)%2Fapi%2F%5B...slug%5D%2Froute.ts&appDir=%2Fmnt%2Fc%2FUsers%2Fdavid%2Fproj%2F***%2Fsrc%2Fapp&pageExtensions=tsx&pageExtensions=ts&pageExtensions=jsx&pageExtensions=js&rootDir=%2Fmnt%2Fc%2FUsers%2Fdavid%2Fproj%2F***&isDev=true&tsconfigPath=tsconfig.json&basePath=&assetPrefix=&nextConfigOutput=&preferredRegion=&middlewareConfig=e30%3D&isGlobalNotFoundEnabled=!:320:13)
at async doRender (/mnt/c/Users/david/proj/***/node_modules/next/dist/server/base-server.js:1586:34)
at async DevServer.renderToResponseWithComponentsImpl (/mnt/c/Users/david/proj/***/node_modules/next/dist/server/base-server.js:1928:13)
at async DevServer.renderPageComponent (/mnt/c/Users/david/proj/***/node_modules/next/dist/server/base-server.js:2394:24)
at async DevServer.renderToResponseImpl (/mnt/c/Users/david/proj/***/node_modules/next/dist/server/base-server.js:2434:32)
at async DevServer.pipeImpl (/mnt/c/Users/david/proj/***/node_modules/next/dist/server/base-server.js:1034:25)
at async NextNodeServer.handleCatchallRenderRequest (/mnt/c/Users/david/proj/***/node_modules/next/dist/server/next-server.js:393:17)
at async DevServer.handleRequestImpl (/mnt/c/Users/david/proj/***/node_modules/next/dist/server/base-server.js:925:17)
at async /mnt/c/Users/david/proj/***/node_modules/next/dist/server/dev/next-dev-server.js:398:20
at async Span.traceAsyncFn (/mnt/c/Users/david/proj/***/node_modules/next/dist/trace/trace.js:157:20)
at async DevServer.handleRequest (/mnt/c/Users/david/proj/***/node_modules/next/dist/server/dev/next-dev-server.js:394:24)
at async invokeRender (/mnt/c/Users/david/proj/***/node_modules/next/dist/server/lib/router-server.js:239:21)
at async handleRequest (/mnt/c/Users/david/proj/***/node_modules/next/dist/server/lib/router-server.js:436:24)
at async requestHandlerImpl (/mnt/c/Users/david/proj/***/node_modules/next/dist/server/lib/router-server.js:464:13)
at async Server.requestListener (/mnt/c/Users/david/proj/***/node_modules/next/dist/server/lib/start-server.js:218:13)
"data": null,
"isOperational": true,
"isPublic": false,
"status": 500,
"name": "APIError"
}
PATCH /api/folders/68d02a978266b5ac0c536b88?depth=0&fallback-locale=null 500 in 69ms
Apparently it still uses the hardcoded payload-folders slug in some places. In this case, the problem is here:
Instead of using the configured slug, it uses the hardcoded one from constants.js. (I would assume similar issues would surface when changing the field name, as it also exists in that file.)
Link to the code that reproduces this issue
(sorry guys but last time I built a project with Payload - back then V2 - I reported so many bugs, if I also had to create a separate project for each it would have cost me my whole day... it's too high a barrier to reporting bugs for me, I am afraid! Instead, I try to point out where the issue is, if I can see that. I do this for you, after all... for myself I always just add a workaround, I can't wait for fixes anyway!)
Reproduction Steps
Set { folders: { slug: 'folders' } } on your project. Create a folder. Then, try to edit the folder.
Which area(s) are affected? (Select all that apply)
area: core
Environment Info
Irrelevant for this bug
@CherryDT will you please allow me to work on this?
🚀 This is included in version v3.57.0
This issue has been automatically locked.
Please open a new issue if this issue persists with any additional detail.