Replace panicking .unwrap()/.expect() with error propagation in production code#142
Merged
Merged
Conversation
…on code Agent-Logs-Url: https://github.com/strawgate/memagent/sessions/1d28d2e0-4751-41b5-b639-011b4810f211 Co-authored-by: strawgate <6384545+strawgate@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Replace .unwrap()/.expect() panics with error propagation in production code
Replace panicking .unwrap()/.expect() with error propagation in production code
Mar 30, 2026
Copilot stopped work on behalf of
strawgate due to an error
March 30, 2026 01:29
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Several production code paths could crash the daemon via unrecoverable panics — lock poisoning cascades, unchecked HTTP header construction, and
finish_batch()schema assertions that swallow the error type entirely.Changes
Lock poisoning (
enrichment.rs)5×
.expect("*lock poisoned")onRwLockreplaced with.unwrap_or_else(|e| e.into_inner()). A panicking thread no longer poisonsK8sPathTable,CsvFileTable, andJsonLinesFileTablefor all subsequent readers/writers.HTTP header construction (
diagnostics.rs,main.rs)6×
.unwrap()ontiny_http::Header::from_bytes()replaced withmap_err(|()| io::Error::other(...))?in functions that already returnResult.Builder
finish_batch()(storage_builder.rs,streaming_builder.rs)Return type changed from
RecordBatchtoResult<RecordBatch, ArrowError>;.expect()replaced with?.Scanner
scan()(scanner.rs)Both
SimdScanner::scan()andStreamingSimdScanner::scan()now returnResult<RecordBatch, ArrowError>. UTF-8 validation failures returnErr(ArrowError::InvalidArgumentError(...))instead of panicking:#[should_panic]tests converted toassert!(result.is_err()).Pipeline error handling (
pipeline.rs)Scan stage now handles
Resultfromscan(), returningio::Erroron failure rather than unwinding.Callsite updates
All bench, example, fuzz-target, and integration-test callers of the changed APIs updated to
.expect()/.unwrap()as appropriate for non-production code.💬 Send tasks to Copilot coding agent from Slack and Teams to turn conversations into code. Copilot posts an update in your thread when it's finished.