Skip to content

Conversation

@redgoat650
Copy link
Contributor

Add JSON output flag for snapshot verify. Return and output a JSON-formatted result including stats and error strings.

* Add JSON output flag for snapshot verify
@codecov
Copy link

codecov bot commented Jun 2, 2025

Codecov Report

Attention: Patch coverage is 97.87234% with 1 line in your changes missing coverage. Please review.

Project coverage is 76.43%. Comparing base (cb455c6) to head (394152c).
Report is 582 commits behind head on master.

Files with missing lines Patch % Lines
snapshot/snapshotfs/snapshot_verifier.go 95.83% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4644      +/-   ##
==========================================
+ Coverage   75.86%   76.43%   +0.57%     
==========================================
  Files         470      529      +59     
  Lines       37301    40201    +2900     
==========================================
+ Hits        28299    30729    +2430     
- Misses       7071     7456     +385     
- Partials     1931     2016      +85     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds JSON output support for the snapshot verify command by returning a structured VerifierResult from the verifier, exposing tree-walker errors via a new GetErrors method, and wiring a --json flag into the CLI.

  • Introduce VerifierResult and update InParallel to return it with JSON tags.
  • Add GetErrors on TreeWalker to expose accumulated errors.
  • Extend CLI to handle --json, suppress default stats, and print JSON; update tests accordingly.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
snapshot/snapshotfs/snapshot_verifier_test.go Updated tests to use new VerifierResult return and check counts and error slices.
snapshot/snapshotfs/snapshot_verifier.go Added VerifierResult type and modified InParallel to build and return it.
snapshot/snapshotfs/snapshot_tree_walker.go Added GetErrors to retrieve a thread-safe copy of errors and count.
cli/command_snapshot_verify.go Added JSON flag handling, suppressed default stats, and printed JSON output.
cli/command_snapshot_verify_test.go Added tests for the --json flag and validation of JSON-formatted results.
Comments suppressed due to low confidence (2)

snapshot/snapshotfs/snapshot_verifier_test.go:70

  • [nitpick] Consider adding an assertion on result.ErrorStrings[0] to verify that the JSON-serializable string matches the expected error message.
		require.ErrorIs(t, result.Errors[0], someErr)

snapshot/snapshotfs/snapshot_verifier_test.go:152

  • The variable err is not declared in this scope before use in result, err = v.InParallel(...), causing a compile error. Declare var err error or use := to define err alongside result.
		var result *snapshotfs.VerifierResult

c.out.printStdout("%s\n", c.jo.jsonIndentedBytes(result, " "))
}

//nolint:wrapcheck
Copy link

Copilot AI Jun 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The //nolint:wrapcheck directive is now obsolete since the wrapped call was removed; consider removing this nolint comment.

Suggested change
//nolint:wrapcheck

Copilot uses AI. Check for mistakes.
@julio-lopez julio-lopez enabled auto-merge (squash) June 24, 2025 20:19
@julio-lopez julio-lopez merged commit b2b0514 into kopia:master Jun 24, 2025
23 checks passed
@julio-lopez julio-lopez deleted the snapshot-verify-json-flag branch June 24, 2025 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants