Skip to content

fix(review): catch findings.json validation errors #2644

Closed

Description

@dan-petty

Problem Description

A findings.json that does not validate against ReviewSessionPayload ends the command with a pydantic traceback. No reader reports the file name or says what to do.

Four readers load the file with ReviewSessionPayload.model_validate_json and no handler. They are devops review findings (commands/review.py, the list), _read_session_file (verify and the other verdict commands), _session_findings (the benchmark) and read_session (review/handoff.py). There is no single loader, so one fix in one place does not cover them.

The case that shows it today: the change for #2504 makes NetworkReputationRecord.outcome a required field. A findings.json written before #2289 holds network_references[].reputation records that have no outcome. Such a file no longer loads. Any later schema change gives the same result for the sessions that exist.

Reproduction Steps

  1. Make a data directory <data> and a session directory <data>/reviews/20261001-000000.
  2. Write findings.json there with this text: {"findings": [], "network_references": [{"target": "203.0.113.7", "reference_type": "ip", "reputation": {"target": "203.0.113.7", "ip": "203.0.113.7", "reputation_summary": "Clean"}}]}.
  3. Run DEVOPS_CLI_DATA_DIR=<data> uv run devops review findings.

Expected vs Actual Behavior

Expected: the command reports the validation error as the existing review error type. The message names the file and the field (network_references.0.reputation.outcome), and the command ends with an exit code and no traceback.

Actual: a Rich traceback that ends with ValidationError: 1 validation error for ReviewSessionPayload.

Environment Diagnostics

devops-cli 0.16.0 with the change for #2504 applied, Linux, Python 3.14. The probe used a temporary data directory and made no network request.

Logs, Traces, or Terminal Output

ValidationError: 1 validation error for ReviewSessionPayload
network_references.0.reputation.outcome
  Field required [type=missing, ...]

Pre-Submission Checklist

  • I have verified that no sensitive credentials, private keys, or internal tokens are contained in this issue report.
  • I have checked existing issues and pull requests to ensure this is not a duplicate.

Source: found while working on #2504.

Proposed design

Problem statement

Four readers of findings.json call ReviewSessionPayload.model_validate_json without catching ValidationError. When a file fails validation after a schema change, the command ends with a raw pydantic traceback. The user sees no file name, no field path, and no guidance on what to do.

Acceptance criteria

Requirement: Shared loader catches validation errors

A single shared loader function SHALL catch pydantic.ValidationError and raise the project's existing review error type.

Scenario: Loader raises review error on invalid file

  • WHEN A findings.json file fails ReviewSessionPayload validation
  • THEN The loader raises the project's review error type, not ValidationError

Requirement: Error message names the file

The error message SHALL include the file path of the findings.json that failed validation.

Scenario: Message contains file path

  • WHEN A findings.json file fails validation
  • THEN The error message contains the full path to that file

Requirement: Error message names the failing field

The error message SHALL include the dotted field path of each validation failure.

Scenario: Message contains field path

  • WHEN A required field is missing in a findings.json file
  • THEN The error message contains the dotted path such as network_references.0.reputation.outcome

Requirement: No traceback on validation failure

The command SHALL exit with a non-zero exit code and no traceback when findings.json fails validation.

Scenario: Clean exit on invalid file

  • WHEN A findings.json file fails validation
  • THEN The process exits with a non-zero code and the output contains no Python traceback

Requirement: All four readers use the shared loader

All four readers of findings.json SHALL call the shared loader instead of model_validate_json directly.

Scenario: All call sites updated

  • WHEN The source is inspected
  • THEN The findings list, _read_session_file, _session_findings, and read_session all call the shared loader

Existing Tool Considered

No check has run. Pydantic, which the project already uses for ReviewSessionPayload, provides ValidationError with structured field-path data. The project already has a review error type for command-level errors. No additional library is needed. The written cost is one shared loader function of about 15 lines, four call-site changes, and one test.

Key questions

  • What is the project's existing review error type?: The body names it as 'the existing review error type.' The class is defined in the review command module. Refine must confirm the exact class name and its exit-code behavior from the source. [sources: src/devops_cli/commands/review.py]
  • Should the fix create a single shared loader or add try/except at each of the four sites?: Create a single shared loader. The body states 'There is no single loader, so one fix in one place does not cover them,' which identifies the missing loader as the root cause. A shared loader gives one place to format the message and one place to test. (best practice) [sources: src/devops_cli/commands/review.py:1151, src/devops_cli/commands/review.py:2028, src/devops_cli/ai/review/exporter.py:166]
    • Chosen: Single shared loader function. One place to format the error, one place to test, and the body identifies the missing loader as the root cause.
    • Rejected: try/except at each of the four call sites. Duplicates the formatting logic four times and leaves room for a fifth reader to miss the handler.
  • What must the error message contain?: The file path and the dotted field path of each validation failure. The body gives the example network_references.0.reputation.outcome. [sources: src/devops_cli/commands/review.py]
  • What exit code does the command produce on this error?: A non-zero exit code set by the project's existing review error type. The body requires 'an exit code and no traceback.' Refine must confirm the exact code from the error class. [sources: src/devops_cli/commands/review.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    status/new
    value/medium
    effort/medium
    on Oct 29, 2026
  2. dan-petty commented on Oct 29, 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 command ends with an unhandled traceback instead of a clean error message; this is a defect in error handling.
    • Priority: P2-Medium. The user can still read the traceback, so the command is not fully broken, but the experience is poor and the fix is straightforward.
    • Value: Medium. A clean error message that names the file and field helps users diagnose schema mismatches without reading a stack trace.
    • Effort: Medium. Four separate readers load findings.json with no shared loader, so the fix touches multiple call sites.
    • Related: fix(review): ReviewProfile verdict_distributions schema rejects float citation_rates #640, which asks for a different change. Both deal with a pydantic ValidationError crashing a review command, but #640 fixes a type annotation in ReviewProfile while the candidate adds error handling to four findings.json readers.
  3. added
    priority/p2-medium
    scope/review
    on Oct 29, 2026
  4. added
    status/ready
    and removed
    status/new
    on Oct 30, 2026
  5. devops-cli-service commented on Oct 30, 2026

    @devops-cli-service
    Contributor

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

  6. devops-cli-service commented on Nov 2, 2026

    @devops-cli-service
    Contributor

    Staged: branch fix/2644-a-findings-json-that-does-not, draft pull request #3147. The pull request plans the item and closes no issue.

    The task groups, with the tokens of the inputs of each step, for a budget of 40000 tokens:

    1. Add shared session payload loader: 4760 tokens
    2. Route all four readers through the shared loader: 4661 tokens
  7. added
    status/planned
    and removed
    status/ready
    on Nov 2, 2026
  8. changed the title [-]fix(review): a findings.json that does not validate ends the command with a traceback[/-] [+]fix(review): catch findings.json validation errors[/+] on Nov 6, 2026
  9. dan-petty commented on Nov 6, 2026

    @dan-petty
    OwnerAuthor

    The job shortened the title of this item. The summary had 72 characters, and the limit is 60. The type and the scope stay.

  10. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/planned
    status/in-progress
    on Nov 6, 2026
  11. removed
    status/in-review
    owner/agent
    on Nov 6, 2026
  12. devops-cli-service commented on Nov 6, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-06 22:09 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/mediumpriority/p2-mediumscope/reviewsource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions