Skip to content

fix: follow the CLI version's notebook header rule, which v1.24.0 changed - #362

Merged
cornzyblack merged 1 commit into
mainfrom
fix/361-notebook-header-rule
Nov 6, 2026
Merged

cornzyblack merged 1 commit into
mainfrom
fix/361-notebook-header-rule

Conversation

@cornzyblack

@cornzyblack cornzyblack commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #361.

Databricks CLI v1.24.0 changed how it tells a notebook from a plain file (databricks/cli#7290, detectSource in libs/notebook/detect.go):

  • Before v1.24.0: the first line, from the first 32 bytes, must be exactly the header for the extension (# Databricks notebook source for .py).
  • v1.24.0: the first line, from the first 200 bytes, must contain Databricks notebook source, in any comment style.

The inspector always used the old rule, so on v1.24.0 it warned "may not be a notebook" for files the CLI takes as notebooks, and missed "may be a notebook, not a file" for file tasks the CLI rejects.

What changes

  • validateBundle returns the version of the CLI that validated. notebookHeaderRuleFor picks the rule from it: exact before v1.24.0, contains from v1.24.0 on, and contains when the version can't be read. The extension and the Problems panel pass it to extractBundleGraph, which uses it for task paths, pipeline libraries and "Did you mean" suggestions.
  • On an older CLI, a file whose first line has the marker but isn't exactly the header gets a hint that says why (a byte order mark or other text on the line) and that a newer CLI takes it.
  • New CLI test, npm run test:notebook-rule:cli, a CI step on the oldest supported CLI and on CLI latest. For every job task in the notebook-paths fixture it runs bundle validate against a fake workspace on 127.0.0.1 (no login, nothing real contacted) and fails when the CLI and the inspector disagree. If a later CLI release changes the rule again, CLI latest fails and names the task.
  • docs/checks.md and the fixture README describe both rules.

How it was checked

  • CLI v0.299.2 and v1.24.0, on a real workspace first (one task per bundle; the empty .bundle folder validate created was deleted), then with the fake workspace, with the same results:
Task → file v0.299.2 v1.24.0
notebook_task → byte order mark + header not a notebook OK
notebook_task → header + more text not a notebook OK
notebook_task → -- Databricks notebook source in a .py not a notebook OK
notebook_task → print("Databricks notebook source") not a notebook OK
notebook_task → marker ending at byte 190 not a notebook OK
notebook_task → marker after byte 200 not a notebook not a notebook
spark_python_task → byte order mark + header OK is a notebook
  • The newer rule is the workspace's own import rule (the CLI PR says so). Checked with databricks workspace import --format AUTO on v1.24.0: the workspace stored print("Databricks notebook source") as a Python notebook, the byte order mark file as a Python notebook, and a plain script as a file. The test folder was deleted. docs/checks.md notes that the marker line doesn't have to be a comment.
  • npm run test:notebook-rule:cli passes on both. With the exact rule forced, it fails on v1.24.0 and lists the 6 tasks where the CLI and the inspector disagree.
  • A demo bundle through the inspector's own pipeline: on v0.299.2 it warns on the byte order mark and extra text notebooks; on v1.24.0 it doesn't, and warns on the file task instead. Both match bundle validate.
  • npm run test:semantic:cli:matrix, test:semantic:cli, test:variables:cli on both CLIs; npm test (1219 passed), typecheck, lint, build.

Limits

  • The CLI test runs job tasks only. Pipeline libraries use the same rule in the inspector, but the CLI check for them was last confirmed on v1.17.0.
  • Sync, which files bundle deploy uploads as notebooks, is not checked by the inspector.
  • With no readable version, the newer rule is used, so a user on an older CLI whose version can't be read could see the newer rule's results.

Release: patch, planned for 0.6.4 (Thursday 2026-11-12), with #355 and #360. That makes 3 fragments.

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.

Notebook header check follows the CLI version: v1.24.0 accepts a first line that contains the marker

1 participant