Skip to content

[BUG] pup notebooks update doubles every backslash in markdown cells on each round trip #554

@Okabe-Junya

Description

@Okabe-Junya

Describe the bug

pup notebooks create and pup notebooks update re-escape every backslash in markdown cell text. On each request:

  • Every backslash is duplicated (\\\)
  • One extra \ is prepended before each following * or ~.

The effect compounds across update cycles, so a notebook authored once with \* ends up with dozens of stacked \ after a handful of edits via pup. pup notebooks edit is affected transitively. Regex (\d), paths (path\name), and any backslash-bearing content are equally corrupted.

To Reproduce

Save as /tmp/nb.json:

{
  "data": {
    "type": "notebooks",
    "attributes": {
      "name": "backslash round-trip test",
      "status": "published",
      "time": { "live_span": "1h" },
      "cells": [{
        "type": "notebook_cells",
        "attributes": { "definition": {
          "type": "markdown",
          "text": "A: `\\*`  B: `\\\\*`  C: `path\\name`  D: `\\d`  E: `\\\\\\\\\\\\\\\\`  F: `\\~`"
        }}
      }]
    }
  }
}

and then re-upload N times without editing (with following command)

pup notebooks create --file nb.json 
for i in 1 2 3; do
  pup notebooks get $NB_ID | jq '{data: {type:"notebooks", attributes: {
    name:.data.attributes.name, status:.data.attributes.status, time:.data.attributes.time,
    cells: [.data.attributes.cells[] | {type, attributes:{definition:.attributes.definition}}]
  }}}' > body.json
  pup notebooks update $NB_ID --file body.json > /dev/null
done

Count the backslash run before each marker's trailing character.

Observed results

Marker Input After create + 1 RT + 2 RT + 3 RT
A \* 1 3 7 15 31
B \\* 2 5 11 23 47
C path\name 1 2 4 8 16
D \d 1 2 4 8 16
E \\\\\\\\ 8 16 32 64 128
F \~ 1 3 7 15 31

Expected behavior

get -? update must be content-preserving. update(get(nb)) should leave definition.text unchanged byte-for-byte.

Environment

  • OS: macOS 26.5
  • Pup version: pup 0.63.0
  • datadog-api-client rev: DataDog/datadog-api-client-rust@d4954b11 (per Cargo.toml)
  • Auth: OAuth2

Metadata

Metadata

Assignees

No one assigned

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions