Skip to content

Commit 8e52481

Browse files
authored
Fix pipeline failures showing up as complete (#1518)
This fixes an issue where packages would show up as passing Phylum's analysis if they failed at any point of the pipeline. Closes #351.
1 parent dfd89eb commit 8e52481

File tree

3 files changed

+26
-25
lines changed

3 files changed

+26
-25
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
2121
### Fixed
2222

2323
- Package subcommand failing to parse API responses
24+
- Packages which cannot be analyzed showing up as having no issues
2425

2526
## 7.1.0 - 2024-09-24
2627

cli/src/commands/packages.rs

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ use crate::api::PhylumApi;
88
use crate::commands::{CommandResult, ExitCode};
99
use crate::filter::{Filter, FilterIssues};
1010
use crate::format::Format;
11-
use crate::print_user_warning;
1211
use crate::types::{PackageSpecifier, PackageSubmitResponse};
12+
use crate::{print_user_failure, print_user_warning};
1313

1414
fn parse_package(matches: &ArgMatches) -> Result<PackageSpecifier> {
1515
// Read required options.
@@ -36,12 +36,20 @@ pub async fn handle_get_package(api: &PhylumApi, matches: &clap::ArgMatches) ->
3636

3737
match resp {
3838
PackageSubmitResponse::AlreadyProcessed(mut resp) if resp.complete => {
39-
let filter = matches.get_one::<String>("filter").and_then(|v| Filter::from_str(v).ok());
40-
if let Some(filter) = filter {
41-
resp.filter(&filter);
42-
}
39+
match resp.pipeline_error {
40+
Some(_) => print_user_failure!(
41+
"Package analysis failed, please contact Phylum if this package exists."
42+
),
43+
None => {
44+
let filter =
45+
matches.get_one::<String>("filter").and_then(|v| Filter::from_str(v).ok());
46+
if let Some(filter) = filter {
47+
resp.filter(&filter);
48+
}
4349

44-
resp.write_stdout(pretty_print);
50+
resp.write_stdout(pretty_print);
51+
},
52+
}
4553
},
4654
PackageSubmitResponse::New => {
4755
print_user_warning!(

cli/src/types.rs

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,9 @@ pub struct Package {
170170
pub complete: bool,
171171
pub release_data: Option<PackageReleaseData>,
172172
pub repo_url: Option<String>,
173+
pub hash: Option<String>,
174+
pub pipeline_error: Option<String>,
175+
pub pipeline_status: Option<PipelineStatus>,
173176
}
174177

175178
#[derive(Serialize, Deserialize)]
@@ -243,25 +246,14 @@ pub enum IgnoredReason {
243246
Other,
244247
}
245248

246-
/// One of the authors of a package.
247-
#[derive(Serialize, Deserialize)]
248-
#[serde(rename_all = "camelCase")]
249-
pub struct Author {
250-
pub name: String,
251-
pub avatar_url: String,
252-
pub email: String,
253-
pub profile_url: String,
254-
}
255-
256-
/// Stats about how responsive the maintainers of a package are.
257-
#[derive(Serialize, Deserialize)]
258-
pub struct DeveloperResponsiveness {
259-
pub open_issue_count: Option<usize>,
260-
pub total_issue_count: Option<usize>,
261-
pub open_issue_avg_duration: Option<u32>,
262-
pub open_pull_request_count: Option<usize>,
263-
pub total_pull_request_count: Option<usize>,
264-
pub open_pull_request_avg_duration: Option<u32>,
249+
/// Package status in the analysis pipeline.
250+
#[derive(Serialize, Deserialize, Copy, Clone, PartialEq, Eq, Debug)]
251+
pub enum PipelineStatus {
252+
Submitted,
253+
Downloading,
254+
Processing,
255+
Analyzing,
256+
Complete,
265257
}
266258

267259
/// Information about when package releases have happened.

0 commit comments

Comments
 (0)