Commit 3472cc3
authored
fix(azuredevops_go): handle empty/invalid timeline responses for YAML… (#8839)
* fix(azuredevops_go): handle empty/invalid timeline responses for YAML-broken builds
Builds that fail due to YAML syntax errors in pipeline definitions return
an empty or non-JSON body from the Timeline API (200 OK with no usable
content). Previously this caused ParseRawMessageFromRecords to propagate
a hard error that aborted the entire collectApiTimelineRecords subtask.
Two complementary fixes:
1. Add ignoreInvalidTimelineResponse AfterResponse handler that supersedes
ignoreDeletedBuilds: it still skips 404s (deleted builds) and now also
skips responses with empty or non-JSON bodies by returning
api.ErrIgnoreAndContinue, leaving the rest of the pipeline intact.
The body is peeked and then restored via io.NopCloser so the downstream
ResponseParser can still read it when the body is valid JSON.
2. Extend the DB query in CollectRecords to exclude builds with
result = 'none' in addition to result = 'failed'. Builds broken by
YAML syntax errors are categorised as 'none' by Azure DevOps (already
mapped to RESULT_FAILURE in cicdBuildResultRule), so fetching their
timeline is both unnecessary and the primary source of the bad
responses. Using NOT IN ? with a []string slice follows the same
pattern used in blueprint_helper.go.
Unit tests added for ignoreInvalidTimelineResponse covering: 404,
empty body, non-JSON body, valid JSON (nil error + body restored),
and valid empty JSON object.
Fixes: #8838
Signed-off-by: Cornelius Schuchardt <cornelius.schuchardt@beck.de>
* fix(azuredevops_go): remove unused ignoreDeletedBuilds function
The ignoreDeletedBuilds function was replaced by
ignoreInvalidTimelineResponse
in ci_cd_timeline_records_collector.go but was left behind in shared.go.
This caused the 'unused' linter to fail with exit code 2.
* fix: resolve govet non-constant format string warnings
Use constant format verbs instead of dynamic strings passed directly
as format arguments to avoid govet printf-family warnings:
- core/migration/linter: fmt.Errorf with string concat replaced by %s verb
- impls/logruslog: Warn/Error pass pre-formatted message via "%s" arg
instead of using it directly as the format string
---------
Signed-off-by: Cornelius Schuchardt <cornelius.schuchardt@beck.de>1 parent 16c5b92 commit 3472cc3
5 files changed
Lines changed: 103 additions & 8 deletions
File tree
- backend
- core/migration/linter
- impls/logruslog
- plugins/azuredevops_go/tasks
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
79 | | - | |
| 79 | + | |
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
52 | | - | |
| 52 | + | |
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
23 | 28 | | |
24 | 29 | | |
25 | 30 | | |
26 | 31 | | |
27 | | - | |
28 | | - | |
29 | 32 | | |
30 | 33 | | |
31 | 34 | | |
| |||
145 | 148 | | |
146 | 149 | | |
147 | 150 | | |
148 | | - | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
149 | 157 | | |
150 | 158 | | |
151 | 159 | | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
152 | 175 | | |
153 | 176 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
0 commit comments