Skip to content

fix(roadmap): a criterion of group 0 escapes the plan reader #3591

Closed

Description

@dan-petty

Problem

read_change in src/devops_cli/roadmap/plan_read.py reads the criteria list outside its try block. A criterion with Group 0 makes StageCriterion raise pydantic.ValidationError. The error leaves the reader. plan-check and plan-recheck catch only PlanReadError, so the command ends with an uncaught error.

Reproduction

On origin/main at d254410:

  1. Render a change folder with one criterion, such as {"criterion": "The command prints one line for each problem", "group": 1}.
  2. In tasks.md, change Group 1: to Group 0:.
  3. Call read_change on the files.

Result: ValidationError: 1 validation error for StageCriterion.

Expected

The reader raises PlanReadError that names tasks.md and gives the reason. The plan check then reports the file and goes on.

Found by

The premise check of #3498.

Proposed design

Problem statement

A criterion with Group 0 makes StageCriterion raise a pydantic ValidationError inside read_change. The error escapes the reader because _criteria runs outside the try block. plan-check and plan-recheck catch only PlanReadError, so they end with an uncaught error. The reader must convert the validation error into PlanReadError that names tasks.md, so the commands report the file and continue.

Acceptance criteria

Requirement: Criterion validation error becomes a plan read error

The plan reader SHALL raise PlanReadError when StageCriterion rejects a criterion line.

Scenario: Criterion with Group 0

  • WHEN A change folder has the criterion line Group 0: The command prints one line for each problem in tasks.md.
  • THEN read_change raises PlanReadError whose path is tasks.md and whose reason names the group field and the validation problem.

Requirement: Plan check reports an invalid criterion

The plan check SHALL report the tasks.md file and continue when a criterion line has an invalid group number.

Scenario: plan-check with Group 0

  • WHEN devops roadmap plan-check reads a change folder whose tasks.md has the criterion line Group 0: The command prints one line for each problem.
  • THEN The command prints a problem that names tasks.md and exits without an uncaught ValidationError.

Requirement: Plan recheck reports an invalid criterion

The plan recheck SHALL report the tasks.md file and continue when a criterion line has an invalid group number.

Scenario: plan-recheck with Group 0

  • WHEN devops roadmap plan-recheck reads a change folder whose tasks.md has the criterion line Group 0: The command prints one line for each problem.
  • THEN The command prints a problem that names tasks.md and exits without an uncaught ValidationError.

Requirement: Valid criterion groups still parse

The plan reader SHALL keep a criterion line whose group number is valid.

Scenario: Valid Group 1 criterion

  • WHEN A change folder has the criterion line Group 1: The command prints one line for each problem in tasks.md.
  • THEN read_change returns a StageProposal whose criteria list holds one StageCriterion with group equal to 1.

Existing Tool Considered

No alternatives check has run. No open, maintained tool or library covers this need: the defect is in this repository's own read_change and _criteria functions. No tool matches the need, so the plan fixes the existing code instead. The fix is about 5 lines. The written cost to build, keep and fix it is under 500 tokens and under 1 hour elapsed.

Key questions

  • Where does read_change convert the StageCriterion ValidationError into PlanReadError?: Convert it in _criteria with try and except ValidationError. Raise PlanReadError(_TASKS, _reasons(exc)) from the handler. This matches _read_group, which converts the ValidationError of a task group where the group is built. (best practice) [sources: src/devops_cli/roadmap/plan_read.py, openspec/changes/archive/2026-11-04-3482-the-plan-reader-reports-each-bad-plan/design.md]
    • Chosen: Convert in _criteria. It keeps the conversion next to the constructor that raises, as _read_group does.
    • Rejected: Wrap the _criteria call in read_change. It leaves _criteria able to raise a pydantic error and separates the error from its cause.
  • What reason text does the new PlanReadError carry?: Reuse _reasons(exc). It renders each pydantic error on one line with its location and message, and it adds no trace and no URL. (best practice) [sources: src/devops_cli/roadmap/plan_read.py]
    • Chosen: Reuse _reasons(exc). It gives the one-line form that the reader already uses for a bad task group.
    • Rejected: Use str(exc). It includes the input value and a documentation link, and it spans several lines.
    • Rejected: Join exc.errors() by hand. It duplicates _reasons and risks a different format.
  • Should StageCriterion accept Group 0 instead of rejecting it?: No. Keep the group constraint in StageCriterion and convert its ValidationError in the reader. A group number names a task group, and the groups start at 1. (best practice) [sources: src/devops_cli/roadmap/stage_criteria.py, src/devops_cli/roadmap/step_files.py, src/devops_cli/roadmap/plan_read.py]
    • Chosen: Keep the constraint and convert the error. It reports a malformed plan and keeps the criterion tied to a real task group.
    • Rejected: Relax StageCriterion to accept Group 0. It hides a malformed plan and lets a criterion point at no task group.
  • Do plan-check and plan-recheck catch only PlanReadError?: Yes. Both commands catch PlanReadError, so a pydantic ValidationError from read_change escapes them. The fix makes read_change raise PlanReadError for an invalid criterion. [sources: src/devops_cli/roadmap/plan_check.py, src/devops_cli/roadmap/plan_recheck.py]
  • Does _criteria run outside the try block of read_change?: Yes. read_change calls _criteria before the try block that wraps the StageProposal construction. A ValidationError from _criteria therefore leaves the reader. [sources: src/devops_cli/roadmap/plan_read.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/roadmap
    status/new
    value/medium
    effort/low
    on Nov 5, 2026
  2. dan-petty commented on Nov 5, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/roadmap. The (roadmap) scope of the title gives the scope.
    • Priority: P2-Medium. An uncaught error crashes plan-check and plan-recheck for any plan with a Group 0 criterion.
    • Value: Medium. It breaks two commands for a specific but valid input, so users see a traceback instead of a report.
    • Effort: Low. The fix is to move the criteria read inside the existing try block or add a targeted catch.
    • Related: fix(roadmap): the plan reader reports each bad plan with no crash #3482, which asks for a different change. Both concern read_change in plan_read.py letting a ValidationError escape, but the candidate is a new Group-0 case found after #3482 closed.
  3. added
    priority/p2-medium
    on Nov 5, 2026
  4. added
    status/ready
    and removed
    status/new
    on Nov 6, 2026
  5. devops-cli-service commented on Nov 6, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at bd65ef6 (see proposed design in issue body).

  6. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 7, 2026
  7. removed
    status/in-review
    owner/agent
    on Nov 7, 2026
  8. devops-cli-service commented on Nov 7, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-07 05:06 UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/lowpriority/p2-mediumscope/roadmapsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions