Skip to content

fix: update_page properties now update in-place via upsertBlockProperty#49

Open
nlsn wants to merge 1 commit into
ergut:mainfrom
nlsn:fix/update-page-properties
Open

fix: update_page properties now update in-place via upsertBlockProperty#49
nlsn wants to merge 1 commit into
ergut:mainfrom
nlsn:fix/update-page-properties

Conversation

@nlsn
Copy link
Copy Markdown

@nlsn nlsn commented May 18, 2026

Closes #48

Problem

update_page called with a properties dict and no content was routing
through _set_page_level_propertieslogseq.Editor.setPageProperties.
In practice, setPageProperties appended a new block to the page body with
properties serialized as text, rather than updating the existing page-level
property lines in place. The appended block was invisible to Logseq's property
system and the success message was misleading.

Secondary bug: tag values were serialized as Python list repr (['mcp-test'])
instead of Logseq syntax ([[mcp-test]]).

Fix

In src/mcp_logseq/logseq.py, update_page_with_blocks: replaced the
_set_page_level_properties call (and the pre-fetch via
_get_page_level_properties) with a single call to _update_page_properties.

That method calls logseq.Editor.upsertBlockProperty once per key on the
first block (the page-properties pre-block), updating values in place and
implicitly preserving untouched keys.

The tags serialization bug is also resolved — upsertBlockProperty receives a
proper Python list and Logseq renders it correctly as [[tag]] references.

Tests Added

  • test_update_page_properties_only_updates_in_place — regression test;
    asserts no setPageProperties/appendBlockInPage call, and exactly N
    upsertBlockProperty calls targeting the first block
  • Updated test_update_page_append_mode_merges_properties and
    test_update_page_replace_mode_replaces_properties to match new API call
    sequence and result shape

setPageProperties was appending properties as a new block body instead of
updating the existing page-level property lines, making them invisible to
Logseq's property system and rendering tag lists as Python repr strings.

Switch update_page_with_blocks to use _update_page_properties, which calls
upsertBlockProperty on the first block for each key. This updates properties
in-place, preserves unspecified keys implicitly, and fixes tag serialization.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nlsn
Copy link
Copy Markdown
Author

nlsn commented May 18, 2026

Hi @ergut - before merging, I want to flag a potential secondary issue I haven't had time to investigate yet.

The fix routes tag values through upsertBlockProperty with a Python list, which Logseq renders as [[wikilink]]-style page references. This may be the correct behavior, but I want to verify it's consistent with what create_page produces for tags, and that it matches user expectations — plain tags and page references behave differently in Logseq (backlinks, page creation, etc.).

Could you hold off on merging until I've had a chance to test this? Thanks for your patience.

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.

update_page with properties-only appends properties as body block instead of updating page-level properties in place

1 participant