-
Notifications
You must be signed in to change notification settings - Fork 12
src: lore_api_client: use color_eyre::Result #26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,15 @@ | ||
use crate::mailing_list::MailingList; | ||
use crate::patch::{Patch, PatchFeed, PatchRegex}; | ||
use crate::lore_api_client::{ | ||
AvailableListsRequest, FailedAvailableListsRequest, FailedFeedRequest, FailedPatchHTMLRequest, PatchFeedRequest, PatchHTMLRequest | ||
AvailableListsRequest, FailedAvailableListsRequest, FailedPatchHTMLRequest, PatchFeedRequest, PatchHTMLRequest | ||
}; | ||
use std::collections::HashMap; | ||
use std::mem::swap; | ||
use std::{fs::{self, File}, io}; | ||
use std::io::{BufRead, BufReader}; | ||
use std::path::Path; | ||
use std::process::{Command, Stdio}; | ||
use color_eyre::eyre::{bail, Result}; | ||
nanaharris marked this conversation as resolved.
Show resolved
Hide resolved
|
||
use regex::Regex; | ||
use serde_xml_rs::from_str; | ||
|
||
|
@@ -44,14 +45,14 @@ impl LoreSession { | |
self.processed_patches_map.get(message_id) | ||
} | ||
|
||
pub fn process_n_representative_patches<T: PatchFeedRequest>(self: &mut Self, lore_api_client: &T, n: u32) -> Result<(), FailedFeedRequest> { | ||
pub fn process_n_representative_patches<T: PatchFeedRequest>(self: &mut Self, lore_api_client: &T, n: u32) -> Result<()> { | ||
nanaharris marked this conversation as resolved.
Show resolved
Hide resolved
|
||
let mut patch_feed: PatchFeed; | ||
let mut processed_patches_ids: Vec<String>; | ||
|
||
while self.representative_patches_ids.len() < usize::try_from(n).unwrap() { | ||
match lore_api_client.request_patch_feed(&self.target_list, self.min_index) { | ||
Ok(feed_response_body) => patch_feed = from_str(&feed_response_body).unwrap(), | ||
Err(failed_feed_request) => return Err(failed_feed_request), | ||
Err(failed_feed_request) => bail!(failed_feed_request), | ||
Comment on lines
-54
to
+55
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here about recoverable errors. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here about bailed errors still being recoverable |
||
} | ||
|
||
processed_patches_ids = self.process_patches(patch_feed); | ||
|
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I forgot to mention in our offline conversation that it is important for the caller to handle the variants of
FailedFeedRequest
. EspeciallyEndOfFeed
, which is an edge case when we navigate through the whole history of a list. Below, is an explanation of why we need to match here, but my bad on my end for not explaining this earlier... Try accessing a small list (I found theath12k
to have ~1500 patchsets) and navigate to the end of the feed to see the panic happening (it may take a while without the VPN stuff we discussed).Explanation:
Because of logic on the
LoreSession
type, we make subsequent fetches until we hit the number of patchsets we want, so if the page size is 30 and there are 45 patchsets total on a list when the user prompts for the second page, the program would panic, as it would try to access something like this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So in this case, if the request returns an
Err(EndOfFeed)
, this caller should return an Ok(()) rather than propagating the errorMy fault, didn't read the code with enough attention