Skip to content

fix(notebooks): set name when creating from Markdown - #921

Merged
platinummonkey merged 2 commits into
DataDog:mainfrom
hippi345:fix/917-notebook-name
Oct 20, 2026
Merged

platinummonkey merged 2 commits into
DataDog:mainfrom
hippi345:fix/917-notebook-name

Conversation

@hippi345

@hippi345 hippi345 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What does this PR do?

Markdown notebook create now sets a notebook name instead of publishing with an empty name. --name is accepted on pup notebooks create --markdown; when it is omitted, the text of the first ATX heading (#–######, any level) is used. If there is no heading, the name is left empty, matching the previous Markdown create behavior.

The Markdown path writes YAML frontmatter title: (the same key pup's GET-markdown test fixture uses). Only a top-level title: key is replaced; indented / nested title: keys and title: lines inside a block scalar are left alone, and a top-level title: is inserted instead.

Motivation

Fixes #917. pup notebooks create --markdown --file notebook.md stored # Test notebook as cell content and left data.attributes.name as "".

API finding

Proven: The v1 JSON create endpoint (POST /api/v1/notebooks) accepts a required data.attributes.name (NotebookCreateDataAttributes.name: String in the rust client pup pins). Markdown create does not use that JSON body; it POSTs text/markdown to /api/unstable/notebooks.

Proven in-repo: get --markdown is documented as YAML frontmatter + body (docs/COMMANDS.md). The GET-markdown test mocks a server body of ---\ntitle: test\n---\n\n## hi\n (src/commands/notebooks.rs, test_notebooks_get_markdown_requests_markdown_media_type). Pup does not parse that frontmatter; it prints the body as-is.

Inferred, not proven: that POST /api/unstable/notebooks treats YAML title: as data.attributes.name. There is no Datadog public spec for the unstable Markdown endpoint that says so, and this change was not live-round-tripped (no API credentials in this environment).

Before / after

File:

# Test notebook

Hello world!

Before (pup notebooks create --markdown --file notebook.md): posted body is the file as-is; pup notebooks get <id> shows "name": "".

After (same command): posted body is:

---
title: "Test notebook"
---

# Test notebook

Hello world!

--name "Incident notes" sets title: "Incident notes" even when a heading is present. A file with no ATX heading is posted unchanged (empty name).

Additional Notes

  • --name requires --markdown (JSON create still takes the name from the request file).
  • Setext headings are not used as the default name.
  • Headings inside fenced code blocks are ignored.
  • Existing frontmatter: only an unindented top-level title: is updated.

Checklist

  • The code change follows the project conventions (see CONTRIBUTING.md)
  • Tests have been added/updated (if applicable)
  • Documentation has been updated (if applicable)
  • All CI checks pass
  • Code coverage is maintained or improved

Related Issues

Fixes #917

This change was prepared with AI assistance and reviewed by the author.

Markdown create posted the file body as-is, so the first heading became
cell content and data.attributes.name stayed empty.

Add --name for Markdown create. When omitted, use the first ATX heading
(any level). If there is no heading, leave the name empty as before.
The Markdown API stores the name in YAML frontmatter title.
upsert_yaml_title trimmed each frontmatter line before looking for
title:, so a nested mapping key or a title: line inside a block scalar
was replaced instead of inserting a top-level title.
@hippi345
hippi345 marked this pull request as ready for review October 17, 2026 16:22
@hippi345
hippi345 requested a review from a team as a code owner October 17, 2026 16:22
@platinummonkey
platinummonkey merged commit 15f3ca8 into DataDog:main Oct 20, 2026
10 checks passed
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.

[BUG] Markdown notebook creation publishes notebooks with empty names

2 participants