Unable to save new content
To Reproduce
Unsure if it is consistent, but this is what has been causing it for me:
- Create a custom component with a relationship field to a page.
- Add an instance of that component to a page (the root home page
/in my case). - Select that same page as a value for the field on the custom component.
- Publish
- Try making and publishing a change to a different component on that page.
Expected behavior
The changes get saved after clicking "Publish".
Describe the bug
When clicking "Publish", the changes get reverted. The /api/v1/@apostrophecms/page/ does not include any modified data.
Mind you, not every widget seemed equally affected by this. Rich text widgets in particular stopped saving entirely. It might also have to do with the position of the affected component (before/after) relative to the component that includes the recursive relationship.
My assumption is that the recursivity is what causes the issue. While I'm writing this, I'm remembering that the project property on the relationship would most likely fix this issue by excluding the page's content. Still I think this is worth looking into.
Details
Version of Node.js: v20.16.0
Server Operating System: Windows 11 using WSL. The MongoDB database runs in a docker container.
By "component" I assume you mean widget.
Please do try project to see if that addresses it for you.
Are you able to create a test project you can share here that demonstrates the issue? Perhaps a fork of apostrophecms/starter-kit-essentials?
By "component" I assume you mean widget.
I do, that's my bad.
It does appear that using project solves the issue.
As for the test project, I'm on the clock right now but I'll see what I can do for you later today.
Thanks! I agree it would be nice if project wasn't mandatory or if we could at least warn in this situation in a useful way, etc., but it's helpful to know it makes a difference.
I was able to recreate the bug, here's the repo: https://github.com/Pixelguymm/apos-bug-report
After setting this up, I am confident that my suspicions were correct. The bug occurs when there's a relationship to the current page in one of the widgets on that page, unless project is used to include only the URL. I also found out that indeed only the widgets placed after the relationship in the hirarchy are affected. The ones before it work without issue.
I included a few pages demonstrating the bug, they're in the json files I exported from MongoDB. Mind that any time I mention editing a widget, I mean editing it and publishing the changes without them getting lost.
All details regarding OS and node version are the same as the original report.
Thanks for the very thorough bug report!