Skip to content

Commit 8be7bd9

Browse files
fix(dart-symbol-map): Make --url global argument available
The --url argument was not recognized by the dart-symbol-map command because it was missing from the derive parser schema. Added the url field to the SentryCLI struct to allow global --url usage. Also updated the legacy parser to mark --url as global for consistency with other global arguments. Fixes #3106 Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 53f3fa2 commit 8be7bd9

4 files changed

Lines changed: 94 additions & 1 deletion

File tree

src/commands/derive_parser.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ pub(super) struct SentryCLI {
1818
#[arg(help = "Use the given Sentry auth token")]
1919
pub(super) auth_token: Option<AuthToken>,
2020

21+
#[arg(global = true, long, value_name = "URL")]
22+
#[arg(help = "Fully qualified URL to the Sentry server.{n}[default: https://sentry.io/]")]
23+
pub(super) url: Option<String>,
24+
2125
#[arg(global=true, ignore_case=true, value_parser=["trace", "debug", "info", "warn", "error"])]
2226
#[arg(long, help = "Set the log output verbosity")]
2327
pub(super) log_level: Option<String>,

src/commands/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ fn app() -> Command {
154154
.max_term_width(100)
155155
.subcommand_required(true)
156156
.arg_required_else_help(true)
157-
.arg(Arg::new("url").value_name("URL").long("url").help(
157+
.arg(Arg::new("url").value_name("URL").long("url").global(true).help(
158158
"Fully qualified URL to the Sentry server.{n}\
159159
[default: https://sentry.io/]",
160160
))
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"08978d44d46a9c3c0dab8f7aabc46c68": {
3+
"state": "ok",
4+
"detail": null,
5+
"missingChunks": [],
6+
"dif": {
7+
"id": "1",
8+
"uuid": "00000000-0000-0000-0000-000000000000",
9+
"debugId": "00000000-0000-0000-0000-000000000000",
10+
"objectName": "dartsymbolmap.json",
11+
"cpuName": "any",
12+
"headers": {
13+
"Content-Type": "application/octet-stream"
14+
},
15+
"size": 1,
16+
"sha1": "08978d44d46a9c3c0dab8f7aabc46c68",
17+
"dateCreated": "1776-07-04T12:00:00.000Z",
18+
"data": {}
19+
}
20+
}
21+
}

tests/integration/upload_dart_symbol_map.rs

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,71 @@ fn command_upload_dart_symbol_map_invalid_mapping() {
102102
.with_default_token()
103103
.run_and_assert(AssertCommand::Failure);
104104
}
105+
106+
#[test]
107+
fn command_upload_dart_symbol_map_with_custom_url() {
108+
// Test that --url global argument is recognized and used by dart-symbol-map command.
109+
// This verifies the fix for issue #3106.
110+
let call_count = AtomicU8::new(0);
111+
112+
let manager = TestManager::new()
113+
.mock_endpoint(
114+
MockEndpointBuilder::new("GET", "/api/0/organizations/wat-org/chunk-upload/")
115+
.with_response_file("dart_symbol_map/get-chunk-upload.json"),
116+
)
117+
.mock_endpoint(MockEndpointBuilder::new(
118+
"POST",
119+
"/api/0/organizations/wat-org/chunk-upload/",
120+
))
121+
.mock_endpoint(
122+
MockEndpointBuilder::new(
123+
"POST",
124+
"/api/0/projects/wat-org/wat-project/files/difs/assemble/",
125+
)
126+
.with_response_fn(move |request| {
127+
let body = request.body().expect("body should be readable");
128+
let body_json: serde_json::Value = serde_json::from_slice(body)
129+
.expect("request body should be valid JSON");
130+
131+
let (checksum, _obj) = body_json
132+
.as_object()
133+
.and_then(|m| m.iter().next())
134+
.map(|(k, v)| (k.clone(), v.clone()))
135+
.expect("assemble request must contain at least one object");
136+
137+
match call_count.fetch_add(1, Ordering::Relaxed) {
138+
0 => format!(
139+
"{{\"{checksum}\":{{\"state\":\"not_found\",\"missingChunks\":[\"{checksum}\"]}}}}"
140+
)
141+
.into(),
142+
1 => format!(
143+
"{{\"{checksum}\":{{\"state\":\"created\",\"missingChunks\":[]}}}}"
144+
)
145+
.into(),
146+
2 => format!(
147+
"{{\"{checksum}\":{{\"state\":\"ok\",\"detail\":null,\"missingChunks\":[],\"dif\":{{\"id\":\"1\",\"uuid\":\"00000000-0000-0000-0000-000000000000\",\"debugId\":\"00000000-0000-0000-0000-000000000000\",\"objectName\":\"dartsymbolmap.json\",\"cpuName\":\"any\",\"headers\":{{\"Content-Type\":\"application/octet-stream\"}},\"size\":1,\"sha1\":\"{checksum}\",\"dateCreated\":\"1776-07-04T12:00:00.000Z\",\"data\":{{}}}}}}}}"
148+
)
149+
.into(),
150+
n => panic!(
151+
"Only 3 calls to the assemble endpoint expected, but there were {}.",
152+
n + 1
153+
),
154+
}
155+
})
156+
.expect(3),
157+
);
158+
159+
let server_url = manager.server_url();
160+
161+
manager
162+
.assert_cmd([
163+
"--url",
164+
&server_url,
165+
"dart-symbol-map",
166+
"upload",
167+
"tests/integration/_fixtures/dart_symbol_map/dartsymbolmap.json",
168+
"tests/integration/_fixtures/Sentry.Samples.Console.Basic.pdb",
169+
])
170+
.with_default_token()
171+
.run_and_assert(AssertCommand::Success);
172+
}

0 commit comments

Comments
 (0)