fix: tasks.py crashes on malformed tasks.json in archive dirs#28
fix: tasks.py crashes on malformed tasks.json in archive dirs#28benslockedin wants to merge 1 commit intomainfrom
Conversation
Two bugs fixed, one feature added:
**Bug 1: Archive directory crash**
_all_task_files() walked recursively into archive and reference
directories containing legacy tasks.json files with non-v3 schemas.
_read_json() called sys.exit(1), killing the entire save operation.
Fix: skip any directory with "archive" in the name, plus _references
and raw. Collection functions (_collect_all_tasks, _find_task) now
use strict=False mode — warn and skip instead of crashing.
**Bug 2: v2 JSON format not recognized**
Existing tasks.json files using v2 schema ("text" instead of "title",
no "id" field, "normal" priority) passed validation but produced
incorrect output in list/summary commands.
**Feature: auto-migrate v2 tasks on first touch**
Three migration paths, all triggered transparently:
1. v2 JSON upgrade — tasks with "text" and no "id" are upgraded
in-place. Priority "normal" maps to "todo". IDs assigned.
2. Markdown migration — tasks.md files (with or without YAML
frontmatter) are parsed into tasks.json. Section headers
(## Urgent, ## Active, ## To Do, ## Done) map to priority.
Checkboxes, @session assignees, due dates, and completion
dates extracted. Original backed up as tasks.md.v2-backup.
3. Archive skip — directories matching "archive" in name are
excluded from recursive walks.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
658ab2b to
0de1c96
Compare
|
Merge safety review (advisory) — Patrick Brosnan, non-collaborator on Verdict: YELLOW — author response needed. Headline: The PR body advertises a ~40-line archive-skip crash fix (
Plus zero unit tests for the +260 lines of parsing/migration/writing code. Recommendation: Either (a) split the PR — land the archive-skip + The underlying crash fix IS urgent (actively breaking save operations on Conflict with #29: Textual only (both touch Full cross-PR synthesis (conflict matrix, recommended merge order for all 7 open PRs, per-PR verdicts, blocker list): see the cover comment on #29 — #29 (comment) Generated via flow-next epic |
Summary
tasks.pywalks recursively to findtasks.jsonfiles but doesn't skip_archive/,_references/,01_Archive/, orraw/directoriestasks.jsonfiles in these paths (e.g. Airtable exports with different schema) cause_read_json()tosys.exit(1), killing the entire save operationsupernormal-systemswalnut where_archive/reference/airtable-full-export/supernormal-systems/tasks.jsonexists with a v1 schema (no"tasks"key)Changes
_all_task_files()— added_archive,_references,01_Archive,rawtoskip_dirs_read_json()— addedstrict=Falsemode that returnsNone+ prints a warning instead of exiting. Default remainsstrict=Truefor direct operations (add, done, edit) where you want hard failures_collect_all_tasks()+_find_task()— usestrict=Falseand skipNoneresults gracefullyTest plan
tasks.py addon a walnut with legacytasks.jsonin archive paths — should succeedtasks.py liston same walnut — should list tasks, print warning to stderr for skipped filestasks.py addon a walnut with no archive cruft — should work exactly as beforetasks.py donetargeting a task in_kernel/tasks.json— strict mode still exits on malformed kernel file🤖 Generated with Claude Code