Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Handle Actions Cancel Workflow Run returning a 202#855

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
omgitsads merged 4 commits intomainfromhandle-accepted-error
Aug 12, 2025
Merged
Show file tree
Hide file tree
Changes fromall 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
4 changes: 3 additions & 1 deletionpkg/github/actions.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -955,7 +955,9 @@ func CancelWorkflowRun(getClient GetClientFn, t translations.TranslationHelperFu

resp, err := client.Actions.CancelWorkflowRunByID(ctx, owner, repo, runID)
if err != nil {
return ghErrors.NewGitHubAPIErrorResponse(ctx, "failed to cancel workflow run", resp, err), nil
if _, ok := err.(*github.AcceptedError); !ok {
return ghErrors.NewGitHubAPIErrorResponse(ctx, "failed to cancel workflow run", resp, err), nil
}
}
defer func() { _ = resp.Body.Close() }()

Expand Down
29 changes: 26 additions & 3 deletionspkg/github/actions_test.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -323,12 +323,14 @@ func Test_CancelWorkflowRun(t *testing.T) {
{
name: "successful workflow run cancellation",
mockedClient: mock.NewMockedHTTPClient(
mock.WithRequestMatch(
mock.WithRequestMatchHandler(
mock.EndpointPattern{
Pattern: "/repos/owner/repo/actions/runs/12345/cancel",
Method: "POST",
},
"", // Empty response body for 202 Accepted
http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusAccepted)
}),
),
),
requestArgs: map[string]any{
Expand All@@ -338,6 +340,27 @@ func Test_CancelWorkflowRun(t *testing.T) {
},
expectError: false,
},
{
name: "conflict when cancelling a workflow run",
mockedClient: mock.NewMockedHTTPClient(
mock.WithRequestMatchHandler(
mock.EndpointPattern{
Pattern: "/repos/owner/repo/actions/runs/12345/cancel",
Method: "POST",
},
http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusConflict)
}),
),
),
requestArgs: map[string]any{
"owner": "owner",
"repo": "repo",
"run_id": float64(12345),
},
expectError: true,
expectedErrMsg: "failed to cancel workflow run",
},
{
name: "missing required parameter run_id",
mockedClient: mock.NewMockedHTTPClient(),
Expand DownExpand Up@@ -369,7 +392,7 @@ func Test_CancelWorkflowRun(t *testing.T) {
textContent := getTextResult(t, result)

if tc.expectedErrMsg != "" {
assert.Equal(t,tc.expectedErrMsg, textContent.Text)
assert.Contains(t,textContent.Text, tc.expectedErrMsg)
return
}

Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp