Skip to content

Honor --pretty for validation error JSON #3

Description

@irl-dan

Environment

  • Margin 0.4.0
  • macOS 26.2 (build 25C56)
  • Apple silicon
  • Package: Margin-0.4.0-macOS-arm64.pkg
  • Package SHA-256: cb85c8f4bda5fa2c43fb775214d9ff5241d2143cf88d34088c3ea2dc975119a5

Summary

The comments validate help states that --pretty pretty-prints JSON output.
The command ignores this option when validation fails.
The failure JSON is compact and uses one line.

Reproduction steps

  1. Create invalid.md with this content.
# Invalid fixture

<!-- margin:comments:v1
{ this is not valid JSON }
-->
  1. Run this command.
margin comments validate invalid.md --pretty

Actual behavior

The command exits with status 65.
It returns compact JSON on one line.

{"error":{"code":"INVALID_COMMENT_ENVELOPE","message":"The Margin comment envelope is invalid: The data couldn’t be read because it isn’t in the correct format."},"ok":false,"schema":"urn:margin:cli:v1"}

Expected behavior

The command must apply --pretty to success and error JSON.
The error code and exit status must remain unchanged.

Acceptance criteria

  • margin comments validate invalid.md --pretty emits indented JSON.
  • The output ends with one line feed.
  • The command keeps exit status 65.
  • The command keeps error code INVALID_COMMENT_ENVELOPE.
  • Automated tests cover pretty-printed error output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions