Skip to content

0.2a0

Pre-release
Pre-release

Choose a tag to compare

@simonw simonw released this 23 Nov 05:28
eafa1d7

Bug fixes and hardening following a review of 0.1a0. #4

Editing tools

  • insert now inserts whole lines. A line break is added where the inserted text would otherwise run into a neighbouring line, matching the content's existing \r\n or \n endings.
  • insert rejects insert_line values that are negative, past the end of the content or not integers. Previously these silently inserted somewhere else.
  • view returns an error for a malformed or impossible view_range, such as "5", "0,2" or a start past the end of the content.
  • view preserves trailing whitespace, so viewed text can be pasted into str_replace, and now includes version in its output.
  • Lines are split on \n only. Form feeds and Unicode separators no longer count as line breaks, so line numbers match what an editor shows.
  • Batch edits with missing keys, wrong types or non-object items are reported as Edit #N failed errors instead of raising KeyError or TypeError.
  • The batch edit tool rejects an empty edits array.
  • All tools return {"error": ...} for bad input and for any ValueError raised by a store, instead of raising an exception.

Render hook

  • Keys returned by a render hook can no longer override the id, version or status fields.
  • A render hook that raises after a batch edit no longer makes the saved edit look like a failure. The result reports the edits as saved and includes a render_error key.

Stores

  • An edit that leaves the content unchanged no longer creates a new version in SqliteVersionedStore or rewrites the file in DiskStore.
  • create() raises FileExistsError for a duplicate ref in both stores. SqliteVersionedStore previously raised sqlite3.IntegrityError.
  • SqliteVersionedStore.create() writes the object and its first version in a single transaction.
  • SqliteVersionedStore.delete() works when PRAGMA foreign_keys is enabled.
  • DiskStore preserves line endings and file permission bits when editing a file. Previously \r\n was rewritten as \n and the mode was reset.
  • DiskStore resolves symlinks before checking that a ref stays inside its root directory.
  • DiskStore rejects refs ending in .meta.json, so metadata sidecar files can no longer be read or edited as content.
  • DiskStore raises NotFound for directories and ValueError for empty refs and files that are not UTF-8 text.
  • DiskStore removes its temporary file if a write fails.

Everything else

  • Now requires Python 3.11 or higher, and is tested against Python 3.15.
  • Dropped the typing_extensions dependency.
  • EditToolset.tools() is now tested against the real AgentTool from datasette-agent.
  • The README documents tool output, error handling and backend behaviour.