Skip to content

Commit

Permalink
fix(rust): Nullability around headers and frames (#5532)
Browse files Browse the repository at this point in the history
  • Loading branch information
untitaker committed Feb 13, 2024
1 parent 0045a57 commit 6a01567
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions rust_snuba/src/processors/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ struct ExceptionMechanism {
#[derive(Debug, Deserialize, JsonSchema, Default)]
struct StackTrace {
#[serde(default)]
frames: Option<Vec<StackFrame>>,
frames: Option<Vec<Option<StackFrame>>>,
}

#[derive(Debug, Deserialize, JsonSchema)]
Expand Down Expand Up @@ -278,7 +278,7 @@ struct Request {
#[serde(default)]
method: Unicodify,
#[serde(default)]
headers: Option<Vec<(String, Unicodify)>>,
headers: Option<Vec<Option<(String, Unicodify)>>>,
}

// User
Expand Down Expand Up @@ -437,7 +437,12 @@ impl ErrorRow {

// Extract HTTP referrer from the headers list.
let mut http_referer = None;
for (key, value) in from_request.headers.unwrap_or_default() {
for (key, value) in from_request
.headers
.unwrap_or_default()
.into_iter()
.flatten()
{
if key == "Referrer" {
http_referer = value.0;
break;
Expand Down Expand Up @@ -596,6 +601,8 @@ impl ErrorRow {
.unwrap_or_default()
.frames
.unwrap_or_default()
.into_iter()
.flatten()
{
frame_abs_paths.push(frame.abs_path.0);
frame_filenames.push(frame.filename.0);
Expand Down

0 comments on commit 6a01567

Please sign in to comment.