CLI app for developers prototyping atproto functionality
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improve errors for pds_service_auth_rejected and pds_proxied_rejected

authored by

Jack Grigg and committed by
Tangled
7823cc70 638235ee

+36 -11
+36 -11
src/commands/test/labeler/create_report.rs
··· 353 353 } 354 354 } 355 355 356 + impl PdsJwtFetchError { 357 + fn into_diagnostic(self) -> Option<Box<dyn miette::Diagnostic + Send + Sync>> { 358 + match self { 359 + Self::Transport(_) => None, 360 + Self::Failed(resp) | Self::InvalidBody { resp, .. } | Self::MissingToken(resp) => { 361 + let (source_code, span) = body_as_named_source_from_pds(&resp); 362 + let diag = CreateReportDiagnostic::PdsServiceAuthRejected { 363 + status: resp.status.as_u16(), 364 + source_code, 365 + span, 366 + }; 367 + Some(Box::new(diag)) 368 + } 369 + } 370 + } 371 + } 372 + 356 373 /// Fetches a service-auth JWT from a PDS by first creating a session and 357 374 /// then calling `getServiceAuth`. Used in mode-2 (`pds_service_auth_accepted`). 358 375 pub struct PdsJwtFetcher<'a> { ··· 1129 1146 .await 1130 1147 { 1131 1148 Err(e) => { 1132 - results.push(Check::PdsServiceAuthAccepted.network_error(e.to_string())); 1149 + let message = e.to_string(); 1150 + let diagnostic = e.into_diagnostic(); 1151 + results.push(CheckResult { 1152 + diagnostic, 1153 + ..Check::PdsServiceAuthAccepted.network_error(message) 1154 + }); 1133 1155 } 1134 1156 Ok(service_jwt) => { 1135 1157 match report_tee ··· 1171 1193 Ok(resp) => { 1172 1194 // PDS surfaced a non-2xx. Interpret per envelope to 1173 1195 // distinguish PDS-side vs labeler-side: 1196 + let (source_code, span) = body_as_named_source_from_pds(&resp); 1197 + let diag = CreateReportDiagnostic::PdsProxiedRejected { 1198 + status: resp.status.as_u16(), 1199 + source_code, 1200 + span, 1201 + }; 1174 1202 let envelope = XrpcErrorEnvelope::parse(&resp.raw_body); 1175 1203 let err_name = envelope.as_ref().and_then(|e| e.error.clone()); 1176 1204 let is_upstream_label_error = matches!( ··· 1180 1208 || resp.status.as_u16() == 504; 1181 1209 if is_upstream_label_error { 1182 1210 // AC6.2: labeler-side rejection surfaced by PDS. 1183 - let (source_code, span) = body_as_named_source_from_pds(&resp); 1184 - let diag = CreateReportDiagnostic::PdsProxiedRejected { 1185 - status: resp.status.as_u16(), 1186 - source_code, 1187 - span, 1188 - }; 1189 1211 results.push(Check::PdsProxiedAccepted.spec_violation(diag)); 1190 1212 } else { 1191 1213 // AC6.3: PDS-side rejection of the proxy attempt. 1192 - results.push(Check::PdsProxiedAccepted.network_error(format!( 1193 - "PDS rejected proxy attempt with status {}", 1194 - resp.status 1195 - ))); 1214 + results.push(CheckResult { 1215 + diagnostic: Some(Box::new(diag)), 1216 + ..Check::PdsProxiedAccepted.network_error(format!( 1217 + "PDS rejected proxy attempt with status {}", 1218 + resp.status 1219 + )) 1220 + }); 1196 1221 } 1197 1222 } 1198 1223 }