diff --git a/internal/cmdutil/json_error.go b/internal/cmdutil/json_error.go index eb73f4d4..91738d9f 100644 --- a/internal/cmdutil/json_error.go +++ b/internal/cmdutil/json_error.go @@ -181,7 +181,7 @@ func GlobalJSONError(err error) JSONErrorResponse { // exists; retry the follow-up command once the snapshot finishes. case strings.Contains(lower, "schema refreshing"): status = "action_required" - code = "schema_snapshot_not_ready" + code = "schema_refreshing" nextSteps = []string{ "Wait for the branch schema snapshot to become ready, then retry", } @@ -202,7 +202,7 @@ func GlobalJSONError(err error) JSONErrorResponse { nextSteps = []string{ "Wait for the active vtctld mutation or deploy to finish, then retry", } - case "schema_snapshot_not_ready": + case "schema_refreshing", "schema_snapshot_not_ready": status = "action_required" nextSteps = []string{ "Wait for the branch schema snapshot to become ready, then retry", diff --git a/internal/cmdutil/json_error_test.go b/internal/cmdutil/json_error_test.go index dd0e0630..d1acf92b 100644 --- a/internal/cmdutil/json_error_test.go +++ b/internal/cmdutil/json_error_test.go @@ -180,7 +180,23 @@ func TestGlobalJSONErrorSchemaRefreshing(t *testing.T) { if resp.Status != "action_required" { t.Fatalf("status = %q", resp.Status) } - if resp.Code() != "schema_snapshot_not_ready" { + if resp.Code() != "schema_refreshing" { + t.Fatalf("code = %q", resp.Code()) + } + if len(resp.NextSteps) != 1 || resp.NextSteps[0] != "Wait for the branch schema snapshot to become ready, then retry" { + t.Fatalf("next_steps = %#v", resp.NextSteps) + } +} + +func TestGlobalJSONErrorSchemaRefreshingAPICode(t *testing.T) { + resp := GlobalJSONError(&planetscale.Error{ + APICode: "schema_refreshing", + }) + + if resp.Status != "action_required" { + t.Fatalf("status = %q", resp.Status) + } + if resp.Code() != "schema_refreshing" { t.Fatalf("code = %q", resp.Code()) } if len(resp.NextSteps) != 1 || resp.NextSteps[0] != "Wait for the branch schema snapshot to become ready, then retry" {