Classify pinned Copilot admission failures without echoing provider data

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-09-28 14:26:14 -05:00
1 parent aa3f544296
commit f77ae83aeb
1 file changed
+27
@@ -694,6 +694,9 @@ fn response_error_classification(error: &ResponseError) -> &'static str {
"AGENT_STARTUP_FAILED.OTHER" => return "agent_startup_other",
"AGENT_DISCONNECTED" => return "agent_disconnected",
"AUTH_REQUIRED" => return "authentication_required",
"COPILOT_AUTH_REQUIRED" => return "authentication_required",
"COPILOT_ENTITLEMENT_DENIED" => return "provider_entitlement_denied",
"COPILOT_MODEL_UNAVAILABLE" => return "requested_model_unsupported",
"SESSION_RESUME_REQUIRED" => return "session_resume_required",
"SESSION_MODE_REPLAY_FAILED" => return "session_mode_replay_failed",
"SESSION_MODEL_REPLAY_FAILED" => return "session_model_replay_failed",
@@ -804,6 +807,30 @@ mod tests {
}
}
#[test]
fn candidate_auth_diagnostics_use_only_closed_codes_and_never_provider_text() {
for (code, expected) in [
("COPILOT_AUTH_REQUIRED", "authentication_required"),
("COPILOT_ENTITLEMENT_DENIED", "provider_entitlement_denied"),
("COPILOT_MODEL_UNAVAILABLE", "requested_model_unsupported"),
("COPILOT_AUTH_REQUIRED_EXTRA", "unclassified"),
("COPILOT_REQUEST_FAILED", "unclassified"),
("UNKNOWN_CANDIDATE_FAILURE", "unclassified"),
] {
let error = ResponseError {
code: code.to_owned(),
message:
"private-token-canary COPILOT_AUTH_REQUIRED https://user:secret@example.invalid"
.to_owned(),
retryable: false,
};
let classification = response_error_classification(&error);
assert_eq!(classification, expected);
assert!(!classification.contains("canary"));
assert!(!classification.contains("secret"));
}
}
#[test]
fn classifies_only_allowlisted_internal_sidecar_failures() {
let error = |code: &str, message: &str| ResponseError {