Skip to content

Server: Resolves #16132: Publishing/syncing an old note (serialized before the trash feature) throws Missing property "deleted_time" - #16175

Open
Rygaa wants to merge 3 commits into
laurent22:devfrom
Rygaa:issue16132
Open

Server: Resolves #16132: Publishing/syncing an old note (serialized before the trash feature) throws Missing property "deleted_time"#16175
Rygaa wants to merge 3 commits into
laurent22:devfrom
Rygaa:issue16132

Conversation

@Rygaa

@Rygaa Rygaa commented Aug 9, 2026

Copy link
Copy Markdown
Collaborator

Resolves #16132

My change was simple I just made sure old notes with no deleted_time field don't crash the trash/read-only check. A missing deleted_time now means "not in trash" instead of throwing.

I also added two tests. Both use an old note that has no deleted_time field:

  • Test 1: the read-only check does not throw and returns false.
  • Test 2: itemIsInTrash does not throw and returns false.

@Rygaa Rygaa self-assigned this Aug 9, 2026
@coderabbitai coderabbitai Bot added the bug It's a bug label Aug 9, 2026
@joplin-coderabbit-cleanup joplin-coderabbit-cleanup Bot deleted a comment from coderabbitai Bot Aug 9, 2026
@laurent22

laurent22 commented Aug 9, 2026

Copy link
Copy Markdown
Owner

But also why is the introduction of the notebook publishing feature causing this bug? Is there maybe a code path that shouldn't exist, or that could be tweaked? What exactly is making it throw here?

The problem with silently ignoring items without a deleted_time property is that the caller may forget to include that property, and in that case we would actually want to throw. Basically it would be good to better understand what is happening before making the code less strict

@Rygaa

Rygaa commented Aug 10, 2026

Copy link
Copy Markdown
Collaborator Author

But also why is the introduction of the notebook publishing feature causing this bug? Is there maybe a code path that shouldn't exist, or that could be tweaked? What exactly is making it throw here?

The problem with silently ignoring items without a deleted_time property is that the caller may forget to include that property, and in that case we would actually want to throw. Basically it would be good to better understand what is happening before making the code less strict

In #15276, I called itemIsInTrash which wasn't used anywhere else before in packages/server Which caused the issue

A note object reaches itemIsInTrash in 2 ways: rebuilt from stored content itemToJoplinItem JSON.parse(content), or loaded from the DB.

  • Rebuilt from content: old notes have no deleted_time. We can default deleted_time to 0 at rebuild time.
  • Loaded from DB: notes.deleted_time defaults to 0, so the key is always there. If it is missing we should throw

So I keep the checkObjectHasProperties guard for the DB case, and just fix the content case by defaulting the value there

@laurent22

Copy link
Copy Markdown
Owner

So is there a better solution than what you are currently proposing?

@Rygaa

Rygaa commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator Author

So is there a better solution than what you are currently proposing?

I spoke with Henry today and we come to the conclusion that it is indeed better to keep the guard as it was before but just make sure to default deleted_time to 0 during content rebuilt.

I pushed the new changes

@coderabbitai coderabbitai Bot added the server Issues related to Joplin Server label Aug 11, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

.

@personalizedrefrigerator

personalizedrefrigerator commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Mobile, Desktop, Cli: Resolves #16132: Publishing/syncing an old note (serialized before the trash feature) throws Missing property "deleted_time" - #16175

It might be better to use the "Server" prefix, so that this change shows up in the server changelog, rather than the client application changelogs.

@Rygaa Rygaa changed the title Mobile, Desktop, Cli: Resolves #16132: Publishing/syncing an old note (serialized before the trash feature) throws Missing property "deleted_time" Server: Resolves #16132: Publishing/syncing an old note (serialized before the trash feature) throws Missing property "deleted_time" Aug 11, 2026
@Rygaa

Rygaa commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator Author

Mobile, Desktop, Cli: Resolves #16132: Publishing/syncing an old note (serialized before the trash feature) throws Missing property "deleted_time" - #16175

It might be better to use the "Server" prefix, so that this change shows up in the server changelog, rather than the client application changelogs.

Indeed the title was more adapted to my initial fix. I updated it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug It's a bug server Issues related to Joplin Server

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Publishing/syncing an old note (serialized before the trash feature) throws Missing property "deleted_time"

3 participants