fix: suppress JSON output for describe affected --upload#2284
fix: suppress JSON output for describe affected --upload#2284
Conversation
When --upload is used, the full affected stacks JSON is no longer dumped to the console by default. Use --verbose to see it. The success message now includes a count of affected components. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Dependency Review✅ No vulnerabilities or license issues found.Snapshot WarningsEnsure that dependencies are being submitted on PR branches and consider enabling retry-on-snapshot-warnings. See the documentation for more information and troubleshooting advice. Scanned FilesNone |
📝 WalkthroughWalkthroughConditionally suppresses the large "Affected components and stacks" output when uploading (unless verbose or an output file is requested) and changes the upload success UI message to include the number of affected components. Adds unit tests covering the upload/output control flow. Changes
Sequence Diagram(s)(omitted) Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add two tests proving that: - Upload path is reached when output is suppressed (Upload=true, Verbose=false) - Output is shown when verbose is enabled (Upload=true, Verbose=true) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
internal/exec/describe_affected_test.go (1)
2079-2168: Consider adding a test forOutputFilescenario.The new conditional in
uploadableQueryhas three branches:!args.Upload,args.Verbose, andargs.OutputFile != "". The tests cover the first two but not the third. A test verifying that output is shown whenUpload=true,Verbose=false, andOutputFileis set would complete the coverage.Example test case
// TestUploadShowsOutputWhenFileSet verifies that when --upload and --file are both set, // the JSON output is written to file (printOrWriteToFile is called). func TestUploadShowsOutputWhenFileSet(t *testing.T) { printCalled := false d := describeAffectedExec{ atmosConfig: &schema.AtmosConfiguration{}, printOrWriteToFile: func(atmosConfig *schema.AtmosConfiguration, format, file string, data any) error { printCalled = true return nil }, IsTTYSupportForStdout: func() bool { return false }, pageCreator: pager.New(), } headRef := plumbing.NewHashReference("refs/heads/feature", plumbing.NewHash("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")) baseRef := plumbing.NewHashReference("refs/heads/main", plumbing.NewHash("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb")) affected := []schema.Affected{ {Component: "vpc", Stack: "dev"}, } err := d.uploadableQuery( &DescribeAffectedCmdArgs{ Upload: true, Verbose: false, OutputFile: "/tmp/affected.json", Format: "json", CIEventType: "pull_request", CLIConfig: &schema.AtmosConfiguration{}, }, "https://github.com/example/repo.git", headRef, baseRef, affected, ) assert.True(t, printCalled, "printOrWriteToFile should be called when --upload and --file are both set") assert.NoError(t, err) }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@internal/exec/describe_affected_test.go` around lines 2079 - 2168, The test suite is missing coverage for the upload branch when OutputFile is provided; add a new unit test that calls describeAffectedExec.uploadableQuery with DescribeAffectedCmdArgs{Upload:true, Verbose:false, OutputFile:"/tmp/affected.json", Format:"json", CIEventType:"pull_request", CLIConfig:...} using a describeAffectedExec whose printOrWriteToFile stub flips a boolean, then assert printOrWriteToFile was called and that uploadableQuery returns no error; reference the same setup as TestUploadSuppressesOutputButStillUploads/TestUploadShowsOutputWhenVerbose (headRef, baseRef, affected, IsTTYSupportForStdout, pageCreator) to keep tests consistent.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@internal/exec/describe_affected_test.go`:
- Around line 2079-2168: The test suite is missing coverage for the upload
branch when OutputFile is provided; add a new unit test that calls
describeAffectedExec.uploadableQuery with DescribeAffectedCmdArgs{Upload:true,
Verbose:false, OutputFile:"/tmp/affected.json", Format:"json",
CIEventType:"pull_request", CLIConfig:...} using a describeAffectedExec whose
printOrWriteToFile stub flips a boolean, then assert printOrWriteToFile was
called and that uploadableQuery returns no error; reference the same setup as
TestUploadSuppressesOutputButStillUploads/TestUploadShowsOutputWhenVerbose
(headRef, baseRef, affected, IsTTYSupportForStdout, pageCreator) to keep tests
consistent.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: a8cc9315-6a41-4eab-a632-b60332adc9fe
📒 Files selected for processing (2)
internal/exec/describe_affected.gointernal/exec/describe_affected_test.go
Codecov Report❌ Patch coverage is
❌ Your patch check has failed because the patch coverage (40.00%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #2284 +/- ##
==========================================
+ Coverage 77.19% 77.22% +0.03%
==========================================
Files 1045 1045
Lines 98388 98389 +1
==========================================
+ Hits 75951 75984 +33
+ Misses 18184 18155 -29
+ Partials 4253 4250 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
what
--uploadis used withatmos describe affected, the full affected stacks JSON is no longer dumped to the console by default--verboseto see the JSON output, or--fileto write it to a filewhy
--verboseor--filereferences
N/A
Summary by CodeRabbit