Skip to content

Commit 3fcf380

Browse files
romtsnclaude
andcommitted
ref(cli): Only show error rows in code-mappings upload table
For large uploads (hundreds of mappings), printing every row floods the terminal. Show only failed mappings in the table since those are actionable; successful ones are already reflected in the summary counts. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1582b72 commit 3fcf380

File tree

5 files changed

+50
-20
lines changed

5 files changed

+50
-20
lines changed

src/commands/code_mappings/upload.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -153,28 +153,28 @@ pub fn execute(matches: &ArgMatches) -> Result<()> {
153153
}
154154
}
155155

156-
// Display results
157-
if !merged.mappings.is_empty() {
156+
// Display error details (successful mappings are summarized in counts only).
157+
let error_mappings: Vec<_> = merged
158+
.mappings
159+
.iter()
160+
.filter(|r| r.status == "error")
161+
.collect();
162+
163+
if !error_mappings.is_empty() {
158164
let mut table = Table::new();
159165
table
160166
.title_row()
161167
.add("Stack Root")
162168
.add("Source Root")
163-
.add("Status");
164-
165-
for result in &merged.mappings {
166-
let status = match result.status.as_str() {
167-
"error" => match &result.detail {
168-
Some(detail) => format!("error: {detail}"),
169-
None => "error".to_owned(),
170-
},
171-
s => s.to_owned(),
172-
};
169+
.add("Detail");
170+
171+
for result in &error_mappings {
172+
let detail = result.detail.as_deref().unwrap_or("unknown error");
173173
table
174174
.add_row()
175175
.add(&result.stack_root)
176176
.add(&result.source_root)
177-
.add(&status);
177+
.add(detail);
178178
}
179179

180180
table.print();
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
```
2+
$ sentry-cli code-mappings upload tests/integration/_fixtures/code_mappings/mappings.json --org wat-org --project wat-project --repo owner/repo --default-branch main
3+
? failed
4+
Uploading 2 code mapping(s)...
5+
+------------------+---------------------------------------------+-------------------+
6+
| Stack Root | Source Root | Detail |
7+
+------------------+---------------------------------------------+-------------------+
8+
| com/example/maps | modules/maps/src/main/java/com/example/maps | duplicate mapping |
9+
+------------------+---------------------------------------------+-------------------+
10+
11+
Created: 1, Updated: 0, Errors: 1
12+
error: 1 error(s) during upload. See details above.
13+
14+
Add --log-level=[info|debug] or export SENTRY_LOG_LEVEL=[info|debug] to see more output.
15+
Please attach the full debug log to all bug reports.
16+
17+
```

tests/integration/_cases/code_mappings/code-mappings-upload.trycmd

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,6 @@
22
$ sentry-cli code-mappings upload tests/integration/_fixtures/code_mappings/mappings.json --org wat-org --project wat-project --repo owner/repo --default-branch main
33
? success
44
Uploading 2 code mapping(s)...
5-
+------------------+---------------------------------------------+---------+
6-
| Stack Root | Source Root | Status |
7-
+------------------+---------------------------------------------+---------+
8-
| com/example/core | modules/core/src/main/java/com/example/core | created |
9-
| com/example/maps | modules/maps/src/main/java/com/example/maps | created |
10-
+------------------+---------------------------------------------+---------+
11-
125
Created: 2, Updated: 0, Errors: 0
136

147
```
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"created": 1,
3+
"updated": 0,
4+
"errors": 1,
5+
"mappings": [
6+
{"stackRoot": "com/example/core", "sourceRoot": "modules/core/src/main/java/com/example/core", "status": "created"},
7+
{"stackRoot": "com/example/maps", "sourceRoot": "modules/maps/src/main/java/com/example/maps", "status": "error", "detail": "duplicate mapping"}
8+
]
9+
}

tests/integration/code_mappings/upload.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,17 @@ fn command_code_mappings_upload() {
1313
.with_default_token();
1414
}
1515

16+
#[test]
17+
fn command_code_mappings_upload_partial_error() {
18+
TestManager::new()
19+
.mock_endpoint(
20+
MockEndpointBuilder::new("POST", "/api/0/organizations/wat-org/code-mappings/bulk/")
21+
.with_response_file("code_mappings/post-bulk-partial-error.json"),
22+
)
23+
.register_trycmd_test("code_mappings/code-mappings-upload-partial-error.trycmd")
24+
.with_default_token();
25+
}
26+
1627
#[test]
1728
fn command_code_mappings_upload_batches() {
1829
// Generate a fixture with 301 mappings to force 2 batches (300 + 1).

0 commit comments

Comments
 (0)