Skip to content

PRO-8223: be careful when assuming doc is an actual doc - #5053

Merged
boutell merged 1 commit into
mainfrom
pro-8223
Sep 2, 2025
Merged

PRO-8223: be careful when assuming doc is an actual doc#5053
boutell merged 1 commit into
mainfrom
pro-8223

Conversation

@boutell

@boutell boutell commented Sep 2, 2025

Copy link
Copy Markdown
Member

I tracked the issue to the render-widget route, which passes the widget to certain document loaders as if it were a document. Trouble occurs when the "areas" loader assumes the "doc" it has been given is a real doc and uses it to impute a value for docId.

This is problematic because docId is intentionally null in the editor dialog.

I corrected the issue by verifying the metaType of doc first.

I also added this check in a few other places.

Finally, one piece of frontend code assumed docId could not be null, so I had to fix that as well.

@boutell
boutell requested a review from myovchev September 2, 2025 18:12
@linear

linear Bot commented Sep 2, 2025

Copy link
Copy Markdown

item._edit = true;
}
item._docId = doc._id;
item._docId = area._docId;

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

set in line 2494, no need to duplicate logic

for (const [ key, val ] of Object.entries(o)) {
if (key === '_docId') {
newObject._docId = o._docId.replace(/:.*$/, '');
newObject._docId = (o._docId == null) ? null : o._docId.replace(/:.*$/, '');

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't crash on null, which is a thing in the modal

@boutell
boutell requested a review from BoDonkey September 2, 2025 18:14
@boutell
boutell merged commit 67d9e2a into main Sep 2, 2025
6 checks passed
@boutell
boutell deleted the pro-8223 branch September 2, 2025 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants