Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion crates/cli/src/output/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,10 @@ fn infer_error_metadata(message: &str) -> (&'static str, bool, Option<String>) {
return ("conflict", false, Some(CONFLICT_SUGGESTION.to_string()));
}

if normalized.contains("does not support") || normalized.contains("unsupported") {
if normalized.contains("does not support")
|| normalized.contains("unsupported")
|| normalized.contains("not yet supported")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid attaching --force hint to generic "not yet supported" errors

Including "not yet supported" in the unsupported-feature matcher makes Formatter::error emit UNSUPPORTED_SUGGESTION for messages that do not have a force path, e.g. diff/mirror local-path rejections and cross-alias cp/mv (crates/cli/src/commands/diff.rs, mirror.rs, cp.rs, mv.rs), whose argument structs have no --force flag. In JSON mode this now returns a misleading recovery action (Retry with --force...) that users and clients cannot apply, whereas previously these cases had no incorrect hint.

Useful? React with 👍 / 👎.

{
return (
"unsupported_feature",
false,
Expand Down Expand Up @@ -541,6 +544,30 @@ mod tests {
}
}

#[test]
fn test_error_descriptor_from_message_infers_conflict() {
let descriptor = ErrorDescriptor::from_message("Destination exists: report.json");
let json = descriptor.to_json_output();

let details = json.details.expect("details should be present");
assert_eq!(details.error_type, "conflict");
assert!(!details.retryable);
assert_eq!(details.suggestion.as_deref(), Some(CONFLICT_SUGGESTION));
}

#[test]
fn test_error_descriptor_from_message_infers_unsupported_feature() {
let descriptor = ErrorDescriptor::from_message(
"Cross-alias S3-to-S3 copy not yet supported. Use download + upload.",
);
let json = descriptor.to_json_output();

let details = json.details.expect("details should be present");
assert_eq!(details.error_type, "unsupported_feature");
assert!(!details.retryable);
assert_eq!(details.suggestion.as_deref(), Some(UNSUPPORTED_SUGGESTION));
}

#[test]
fn test_error_with_suggestion_overrides_default_hint() {
let descriptor = ErrorDescriptor::from_code(
Expand Down