Skip to content

[Bug]: Saving a notebook opened from an .ipynb in verso serve overwrites the .verso file of the same name #114

Closed

Description

@xkqg

Description

Saving a notebook that was opened from a Jupyter file in the browser editor (verso serve) writes it to a .verso file of the same name, and replaces that file without asking if it already exists.

verso convert writes its output beside the input by default, so converting a notebook to Jupyter and later opening the copy in the browser editor is enough: pressing Save replaces the original .verso with what came back from Jupyter. Whatever Jupyter cannot keep is gone — a Mermaid cell and an HTML cell come back as raw cells, and the original is overwritten with them.

What I expected: Save writes the file that was opened (report.ipynb), or asks before replacing an existing report.verso, or offers another name.

From reading the code: NotebookPage.SaveToPathAsync changes the extension to .verso when no serializer keeps the format by default (Jupyter does not), and ServerNotebookService.SaveAsync then writes that path with File.WriteAllTextAsync, whether or not a file is there.

A related detail that makes the loss larger than it needs to be: the Jupyter writer records each cell's Verso type in metadata.verso_type, but the Jupyter reader never reads it back, so a Mermaid or HTML cell — or a cell type an extension adds — returns as a raw cell even from a file Verso wrote itself.

Steps to Reproduce

  1. Save this notebook as report.verso (no third-party extensions involved):

    {
      "verso": "1.1",
      "metadata": { "title": "Report", "defaultKernel": "csharp" },
      "cells": [
        { "id": "6a1f0c52-0b6e-4c43-9a8a-1b7f6f0b1a01", "type": "markdown", "source": "# Quarterly report" },
        { "id": "6a1f0c52-0b6e-4c43-9a8a-1b7f6f0b1a02", "type": "mermaid", "source": "graph TD\n  A[Input] --> B[Output]" },
        { "id": "6a1f0c52-0b6e-4c43-9a8a-1b7f6f0b1a03", "type": "html", "source": "<p><b>Summary</b> goes here.</p>" },
        { "id": "6a1f0c52-0b6e-4c43-9a8a-1b7f6f0b1a04", "type": "code", "language": "csharp", "source": "var answer = 42;" }
      ]
    }
  2. verso convert report.verso --to ipynb — this writes report.ipynb beside it.

  3. verso serve report.ipynb and open it in the browser (I opened it through /?recover=<path>; opening it from the editor's Open button goes through the same save path).

  4. Change nothing and press Save.

  5. Look at report.verso: its cell types were markdown, mermaid, html, code and are now markdown, raw, raw, code.

Error Output

No error is shown. report.verso before Save: markdown, mermaid, html, code
                   report.verso after Save:  markdown, raw, raw, code

Component

Blazor Frontend

Frontend

Blazor (standalone)

Verso Version

1.2.2 (verso CLI 1.2.2+d2247170eeaf0914dd9bca7ad410d45bde8cf47f); the same code is on main at 4927f12

.NET Version

10.0.401 (the browser editor runs on .NET 8)

Operating System

Windows 11 Pro (10.0.26200)

Loaded Extensions

None.

Severity

Critical - data loss, crash, or security issue

Checklist

  • I searched existing issues and this hasn't been reported yet
  • I can reproduce this with no third-party extensions loaded

Activity

  1. TorreyBetts commented on Oct 1, 2026

    @TorreyBetts
    Contributor

    Thanks for the write up. Converting to .verso on save is by design. The CLI parameter --preserve-format (or verso.preserveOriginalFormat in VS Code) is the way to keep the .ipynb. With that said, after some investigation there was a few issues. The serve command was ignoring --preserve-format on Save, and the Jupyter reader never read verso_type back, which is what turned your Mermaid and HTML cells into raw cells. Both are fixed in #117, and saving now asks before it replaces an existing .verso.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions