Skip to content
Open
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions backend/plugins/azuredevops_go/tasks/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,11 @@ func change203To401(res *http.Response) errors.Error {
// that failed due to a YAML syntax error never produce a usable timeline), instead
// of aborting the entire subtask.
func ignoreInvalidTimelineResponse(res *http.Response) errors.Error {
// Keep existing behaviour: treat 404 as a graceful skip (build was deleted).
if res.StatusCode == http.StatusNotFound {
// Treat 404 (build deleted) and 204 (build has no timeline data) as
// graceful skips so the subtask continues instead of failing.
// The 204 guard must come before the body is read because a 204 response
// has an empty body by definition and would cause the JSON parser to fail.
if res.StatusCode == http.StatusNotFound || res.StatusCode == http.StatusNoContent {
return api.ErrIgnoreAndContinue
}

Expand Down
6 changes: 6 additions & 0 deletions backend/plugins/azuredevops_go/tasks/shared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ func TestIgnoreInvalidTimelineResponse_404(t *testing.T) {
assert.Equal(t, api.ErrIgnoreAndContinue, err, "404 should return ErrIgnoreAndContinue")
}

func TestIgnoreInvalidTimelineResponse_204(t *testing.T) {
res := makeResponse(http.StatusNoContent, "")
err := ignoreInvalidTimelineResponse(res)
assert.Equal(t, api.ErrIgnoreAndContinue, err, "204 No Content should return ErrIgnoreAndContinue")
}

func TestIgnoreInvalidTimelineResponse_EmptyBody(t *testing.T) {
res := makeResponse(http.StatusOK, "")
err := ignoreInvalidTimelineResponse(res)
Expand Down