Skip to content

Commit dc40d99

Browse files
author
Alan Donovan
authored
Merge pull request cli#103 from github/fix-EnvironmentNotShutdown
in Start, ignore HTTP 503 with reason 7 EnvironmentNotShutdown
2 parents 3967d0c + 15dab39 commit dc40d99

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

api/api.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,17 @@ func (a *API) StartCodespace(ctx context.Context, token string, codespace *Codes
274274
}
275275

276276
if resp.StatusCode != http.StatusOK {
277-
// Error response is numeric code and/or string message, not JSON.
277+
// Error response is typically a numeric code (not an error message, nor JSON).
278278
if len(b) > 100 {
279279
b = append(b[:97], "..."...)
280280
}
281-
return fmt.Errorf("failed to start codespace: %s", b)
281+
282+
if resp.StatusCode == http.StatusServiceUnavailable && strings.TrimSpace(string(b)) == "7" {
283+
// HTTP 503 with error code 7 (EnvironmentNotShutdown) is benign.
284+
// Ignore it.
285+
} else {
286+
return fmt.Errorf("failed to start codespace: %s", b)
287+
}
282288
}
283289

284290
return nil

0 commit comments

Comments
 (0)