Skip to content

edit_note replace_section and prepend drop blank lines around headings #1815

Closed

Description

@phernandez

Found during live testing of main at 0276799.

Starting from:

## Table

| a | b |
|---|---|
| 1 | 2 |

## Notes

edit_note(operation="replace_section", section="## Table", content="| x | y |\n|---|---|\n| 9 | 8 |") produces:

## Table
| x | y |
|---|---|
| 9 | 8 |
## Notes

The blank line after the heading and the blank line before the next heading are both lost. prepend similarly writes Prepended line.\n# Rich Markdown with no separating blank line. Edits should keep the section's surrounding blank lines and normalize the replacement content's edges.

Activity

  1. added
    bug
    on Oct 23, 2026
  2. claude commented on Oct 23, 2026

    @claude
    Contributor

    Claude finished @phernandez's task in 15s —— View job


    Triage

    • Type: Bug. edit_note with replace_section or prepend removes the blank lines that separate headings from content. That changes the Markdown structure, and in the Table example the table's blank-line separation is lost.
    • Component: MCP tools (edit_note), in the note-editing and content-assembly path. It is not Cloud-specific.
    • Priority: Medium. The note's content and meaning are kept, but the formatting is damaged. Markdown renderers may handle the result differently, especially tables, and repeated edits make the notes harder to read.
    • Complexity: Simple to Medium. The fix is to normalize the leading and trailing newlines of the replacement content in the replace_section and prepend branches. It should also keep the blank lines around the section's heading and the next heading. Regression tests should cover:
      • a table section
      • prepend before a heading
      • content that already has leading or trailing blank lines
      • an empty section
      • the last section in a file
    • Duplicates: A search for similar issues found none.
    • Reproduction: The issue already has a clear repro, so nothing more is needed.

    This is triage only. I haven't made any code changes.

  3. phernandez commented on Oct 23, 2026

    @phernandez
    MemberAuthor

    Folded into the 1.0 tool surface work: #1831 (tracking #1827). This issue stays open until that lands, with a regression test for the behavior described here.

  4. added this to the v1.0 milestone on Oct 29, 2026
  5. phernandez commented on Oct 29, 2026

    @phernandez
    MemberAuthor

    Fixed in the 1.0 tool surface (#1831): bm_edit keeps the blank lines around headings for replace_section and prepend. Regression tests in tests/mcp/test_tool_bm_edit.py and tests/services/test_note_section_edits.py.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions