[ZEPPELIN-6556] Personalized mode leaks a non-owner's paragraph edits into the shared master paragraph - #5360
[ZEPPELIN-6556] Personalized mode leaks a non-owner's paragraph edits into the shared master paragraph#5360xhaktm00 wants to merge 2 commits into
Conversation
42c570e to
2cc99e3
Compare
… into the shared master paragraph
…personalized mode PersonalizeActionsIT.testGraphAction showed that blocking every master-paragraph write in personalized mode also blocked the note owner's changes, so new users no longer inherited them. Guard the master write with an owner check instead: the owner's changes update both the master and their personal copy (previous behavior), while a non-owner's changes stay in their personal copy only.
|
I think there are two separate concerns mixed in here: fixing the leak itself, and deciding what the permission policy for personalized mode should be. If personalized mode is meant to give each user their own view of the note, then arguably even the note owner should not affect the master paragraph while the mode is on. The earlier commit (ac76546) looks closer to that. One thing worth checking before settling on the owner-based gate is the @jongyoul you worked on the original implementation, so you may have the context here. Was the intent that the master paragraph stays frozen while personalized mode is on? |
|
@tbonelee Thank you for the careful review. I've updated the manual verification steps to use |
What is this PR for?
A note can be switched to personalized mode so that each user gets their own copy of a paragraph and one user's form values and results do not affect another's.
However,
NotebookService.runParagraphwrites the caller'sparams,text,titleandconfiginto the shared master paragraph before it checks whether the note is personalized:notebook.saveNote(...)then persists the polluted master. The same ordering exists inupdateParagraph, andsetParagraphUsingMessageis worse: its personalized branch re-fetches the master vianote.getParagraph(paragraphId)instead of resolving the user copy, so it writes the same values into the master twice and never touches the user copy at all.So in personalized mode, a non-owner who edits a dynamic form and runs the paragraph silently overwrites the shared original.
Because
Paragraph.userParagraphMapis transient, the per-user copies do not survive a restart. The corruption stays invisible while the copies exist and surfaces later:Note.clearUserParagraphs) exposes the polluted masterThe fix: resolve the target paragraph first — when the note is personalized, switch to
getUserParagraph(user)before any write — so the master paragraph is never mutated by another user's run or update. Applied torunParagraph,updateParagraphandsetParagraphUsingMessage. Since the two branches wrote identical values, this also removes the duplicated write blocks.The only caller of
setParagraphUsingMessageisspell(), which now records the spell result on the user copy in personalized mode — the intended behavior — instead of on the shared master.Note:
PersonalizeActionsIT.testDynamicFormActionasserts the correct behavior (a non-owner's edit must not leak) but was passing against the old server behavior only because a late WebSocket broadcast reverted the typed form value before the run.What type of PR is it?
Bug Fix
Todos
runParagraph,updateParagraphandsetParagraphUsingMessagesetParagraphUsingMessagere-fetching the master in its personalized branchWhat is the Jira issue?
How should this be tested?
New test
NotebookServiceTest#testRunParagraphInPersonalizedModeDoesNotPolluteMasterParagraph: on a personalized note, it runs and then updates a paragraph asuser1with new params/title, and asserts that the master paragraph's params and title are unchanged whilegetUserParagraph("user1")picks up the new values.Result with the fix:
Tests run: 6, Failures: 0, Errors: 0.Manual verification: create a note with
%md echo "hello, ${name=original}", run it, enable personalized mode, log in as a second user, change the form value and run. Then turn personalized mode off (or restart the server): the paragraph must still showoriginal.Screenshots (if appropriate)
N/A
Questions: