Skip to content

Commit c43696a

Browse files
fix(azuredevops): treat 204 No Content as graceful skip in timeline collector (apache#8958)
1 parent 0e96ba1 commit c43696a

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

backend/plugins/azuredevops_go/tasks/shared.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,11 @@ func change203To401(res *http.Response) errors.Error {
153153
// that failed due to a YAML syntax error never produce a usable timeline), instead
154154
// of aborting the entire subtask.
155155
func ignoreInvalidTimelineResponse(res *http.Response) errors.Error {
156-
// Keep existing behaviour: treat 404 as a graceful skip (build was deleted).
157-
if res.StatusCode == http.StatusNotFound {
156+
// Treat 404 (build deleted) and 204 (build has no timeline data) as
157+
// graceful skips so the subtask continues instead of failing.
158+
// The 204 guard must come before the body is read because a 204 response
159+
// has an empty body by definition and would cause the JSON parser to fail.
160+
if res.StatusCode == http.StatusNotFound || res.StatusCode == http.StatusNoContent {
158161
return api.ErrIgnoreAndContinue
159162
}
160163

backend/plugins/azuredevops_go/tasks/shared_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ func TestIgnoreInvalidTimelineResponse_404(t *testing.T) {
4141
assert.Equal(t, api.ErrIgnoreAndContinue, err, "404 should return ErrIgnoreAndContinue")
4242
}
4343

44+
func TestIgnoreInvalidTimelineResponse_204(t *testing.T) {
45+
res := makeResponse(http.StatusNoContent, "")
46+
err := ignoreInvalidTimelineResponse(res)
47+
assert.Equal(t, api.ErrIgnoreAndContinue, err, "204 No Content should return ErrIgnoreAndContinue")
48+
}
49+
4450
func TestIgnoreInvalidTimelineResponse_EmptyBody(t *testing.T) {
4551
res := makeResponse(http.StatusOK, "")
4652
err := ignoreInvalidTimelineResponse(res)

0 commit comments

Comments
 (0)