Skip to content

Commit b3bd04b

Browse files
timsaucerclaude
andcommitted
Replace .unwrap() with proper error propagation in object store methods
Url::parse() can fail on invalid input. Use .map_err() to convert the error into a Python exception instead of panicking. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 9169146 commit b3bd04b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

crates/core/src/context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ impl PySessionContext {
434434
&upstream_host
435435
};
436436
let url_string = format!("{scheme}{derived_host}");
437-
let url = Url::parse(&url_string).unwrap();
437+
let url = Url::parse(&url_string).map_err(|e| PyValueError::new_err(e.to_string()))?;
438438
self.ctx.runtime_env().register_object_store(&url, store);
439439
Ok(())
440440
}
@@ -448,7 +448,7 @@ impl PySessionContext {
448448
) -> PyDataFusionResult<()> {
449449
let host = host.unwrap_or("");
450450
let url_string = format!("{scheme}{host}");
451-
let url = Url::parse(&url_string).unwrap();
451+
let url = Url::parse(&url_string).map_err(|e| PyDataFusionError::Common(e.to_string()))?;
452452
self.ctx.runtime_env().deregister_object_store(&url)?;
453453
Ok(())
454454
}

0 commit comments

Comments
 (0)