Skip to content

Commit cdcbf5c

Browse files
committed
Address feedback from Avery
1 parent 61f832c commit cdcbf5c

File tree

8 files changed

+34
-8
lines changed

8 files changed

+34
-8
lines changed

crates/rover-client/src/error.rs

+19-2
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,13 @@ pub enum RoverClientError {
139139
check_response: CheckResponse,
140140
},
141141

142-
#[error("The check failed for reasons this Rover version doesn't understand.")]
143-
UnknownCheckFailure { target_url: String },
142+
// While checking the proposed schema, the operations task (and also build task, if run) succeeded,
143+
// but other check tasks failed.
144+
#[error("{}", other_check_task_failure_msg(.has_build_task))]
145+
OtherCheckTaskFailure {
146+
has_build_task: bool,
147+
target_url: String,
148+
},
144149

145150
/// This error occurs when a user has a malformed Graph Ref
146151
#[error("Graph IDs must be in the format <NAME> or <NAME>@<VARIANT>, where <NAME> can only contain letters, numbers, or the characters `-` or `_`, and must be 64 characters or less. <VARIANT> must be 64 characters or less.")]
@@ -182,6 +187,18 @@ pub enum RoverClientError {
182187
ChecksTimeoutError { url: Option<String> },
183188
}
184189

190+
fn other_check_task_failure_msg(has_build_task: &bool) -> String {
191+
let succeeding_tasks = if *has_build_task {
192+
"build and operations tasks have".to_string()
193+
} else {
194+
"operations task has".to_string()
195+
};
196+
format!(
197+
"The {} succeeded, but other check tasks have failed.",
198+
succeeding_tasks
199+
)
200+
}
201+
185202
fn operation_check_error_msg(check_response: &CheckResponse) -> String {
186203
let failure_count = check_response.get_failure_count();
187204
let plural = match failure_count {

crates/rover-client/src/operations/graph/check_workflow/runner.rs

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ fn get_check_response_from_data(
108108
changes,
109109
status,
110110
graph_ref,
111+
false,
111112
core_schema_modified,
112113
)
113114
}

crates/rover-client/src/operations/subgraph/check_workflow/runner.rs

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ fn get_check_response_from_data(
120120
changes,
121121
status,
122122
graph_ref,
123+
true,
123124
core_schema_modified,
124125
)
125126
} else {

crates/rover-client/src/shared/check_response.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ impl CheckResponse {
3030
changes: Vec<SchemaChange>,
3131
result: ChangeSeverity,
3232
graph_ref: GraphRef,
33+
has_build_task: bool,
3334
core_schema_modified: bool,
3435
) -> Result<CheckResponse, RoverClientError> {
3536
let mut failure_count = 0;
@@ -56,7 +57,8 @@ impl CheckResponse {
5657
}
5758
match check_response.result {
5859
ChangeSeverity::PASS => Ok(check_response),
59-
ChangeSeverity::FAIL => Err(RoverClientError::UnknownCheckFailure {
60+
ChangeSeverity::FAIL => Err(RoverClientError::OtherCheckTaskFailure {
61+
has_build_task,
6062
target_url: check_response.target_url.unwrap_or_else(||
6163
// Note that graph IDs and variants don't need percent-encoding due to their regex restrictions.
6264
format!("https://studio.apollographql.com/graph/{}/checks?variant={}", graph_ref.name, graph_ref.variant)

src/command/output.rs

+2
Original file line numberDiff line numberDiff line change
@@ -835,6 +835,7 @@ mod tests {
835835
ChangeSeverity::PASS,
836836
graph_ref,
837837
true,
838+
true,
838839
);
839840
if let Ok(mock_check_response) = mock_check_response {
840841
let actual_json: JsonOutput = RoverOutput::CheckResponse(mock_check_response).into();
@@ -891,6 +892,7 @@ mod tests {
891892
],
892893
ChangeSeverity::FAIL, graph_ref,
893894
false,
895+
false,
894896
);
895897

896898
if let Err(operation_check_failure) = check_response {

src/error/metadata/codes/E036.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
This error occurs when a check fails but this version of Rover doesn't know how to present the check results. Please upgrade Rover, or view the check in [Apollo Studio](https://studio.apollographql.com/) at the provided link. You can read more about client checks [here](https://www.apollographql.com/docs/studio/schema-checks/).
1+
This check error occurs when the operations task (and build task, if run) have succeeded, but some other check task has failed. Please view the check in [Apollo Studio](https://studio.apollographql.com/) at the provided link to see the failure reason. You can read more about client checks [here](https://www.apollographql.com/docs/studio/schema-checks/).

src/error/metadata/mod.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,11 @@ impl From<&mut saucer::Error> for Metadata {
8989
}),
9090
Some(Code::E030),
9191
),
92-
RoverClientError::UnknownCheckFailure { target_url } => (
93-
Some(Suggestion::FixUnknownCheckFailure {
92+
RoverClientError::OtherCheckTaskFailure {
93+
has_build_task,
94+
target_url,
95+
} => (
96+
Some(Suggestion::FixOtherCheckTaskFailure {
9497
target_url: target_url.clone(),
9598
}),
9699
Some(Code::E036),

src/error/metadata/suggestion.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ pub enum Suggestion {
4343
FixOperationsInSchema {
4444
graph_ref: GraphRef,
4545
},
46-
FixUnknownCheckFailure {
46+
FixOtherCheckTaskFailure {
4747
target_url: String,
4848
},
4949
IncreaseClientTimeout,
@@ -165,7 +165,7 @@ impl Display for Suggestion {
165165
Suggestion::FixSubgraphSchema { graph_ref, subgraph } => format!("The changes in the schema you proposed for subgraph {} are incompatible with supergraph {}. See {} for more information on resolving build errors.", Yellow.normal().paint(subgraph.to_string()), Yellow.normal().paint(graph_ref.to_string()), Cyan.normal().paint("https://www.apollographql.com/docs/federation/errors/")),
166166
Suggestion::FixCompositionErrors => format!("The subgraph schemas you provided are incompatible with each other. See {} for more information on resolving build errors.", Cyan.normal().paint("https://www.apollographql.com/docs/federation/errors/")),
167167
Suggestion::FixOperationsInSchema { graph_ref } => format!("The changes in the schema you proposed are incompatible with graph {}. See {} for more information on resolving operation check errors.", Yellow.normal().paint(graph_ref.to_string()), Cyan.normal().paint("https://www.apollographql.com/docs/studio/schema-checks/")),
168-
Suggestion::FixUnknownCheckFailure { target_url } => format!("See {} to view the failure reason for the check.", Cyan.normal().paint(target_url)),
168+
Suggestion::FixOtherCheckTaskFailure { target_url } => format!("See {} to view the failure reason for the check.", Cyan.normal().paint(target_url)),
169169
Suggestion::IncreaseClientTimeout => "You can try increasing the timeout value by passing a higher value to the --client-timeout option.".to_string(),
170170
Suggestion::IncreaseChecksTimeout {url} => format!("You can try increasing the timeout value by setting APOLLO_CHECKS_TIMEOUT_SECONDS to a higher value in your env. The default value is 300 seconds. You can also view the live check progress by visiting {}.", Cyan.normal().paint(url.clone().unwrap_or_else(|| "https://studio.apollographql.com".to_string()))),
171171
Suggestion::FixChecksInput { graph_ref } => format!("Graph {} has no published schema or is not a composition variant. Please publish a schema or use a different variant.", Yellow.normal().paint(graph_ref.to_string())),

0 commit comments

Comments
 (0)