BlueGit

timfa bluegit

fix: YAML-fout in de editor niet twee keer aankondigen

Lint verpakte de fout van de parser nog eens in ci.err.yaml, zodat de
regel "invalid YAML: invalid YAML: ..." liet zien.

Co-authored-by: tim <tim@timfalken.com>

timfa project_87923614_bot_3aff574f6f98414b945a8799374f9092 · pushed by timfa

Authored 2026-10-22 · 3 weeks ago

Hash
6df82547d16616e0c990aeb259058d8a4bacda47
Parent
ceb7aa19
Pipeline
Failed
2 files changed +10 −2
internal/ci/parse.go +9 −1
@@ -4,6 +4,7 @@
4 4 package ci
5 5
6 6 import (
7 "errors"
7 8 "fmt"
8 9 "strconv"
9 10 "strings"
@@ -37,7 +38,14 @@ func ParseIn(data []byte, read func(string) ([]byte, error)) (Pipeline, error) {
37 38 func Lint(data []byte, read func(string) ([]byte, error)) (Pipeline, []Issue) {
38 39 p, issues, err := parseBytes(data, read, nil)
39 40 if err != nil {
40 issues = append([]Issue{{Line: 1, Key: "ci.err.yaml", Args: []any{err.Error()}}}, issues...)
41 // parseBytes verpakt een YAML-fout al als ci.err.yaml. Nog eens
42 // verpakken geeft "invalid YAML: invalid YAML: ...".
43 line := Issue{Line: 1, Key: "ci.err.yaml", Args: []any{err.Error()}}
44 var ie i18n.Error
45 if errors.As(err, &ie) {
46 line.Key, line.Args = ie.Key, ie.Args
47 }
48 issues = append([]Issue{line}, issues...)
41 49 }
42 50 return p, issues
43 51 }
@@ -4,6 +4,7 @@
4package ci
4package ci
5
5
6import (
6import (
7 "errors"
7 "fmt"
8 "fmt"
8 "strconv"
9 "strconv"
9 "strings"
10 "strings"
@@ -37,7 +38,14 @@ func ParseIn(data []byte, read func(string) ([]byte, error)) (Pipeline, error) {
37func Lint(data []byte, read func(string) ([]byte, error)) (Pipeline, []Issue) {
38func Lint(data []byte, read func(string) ([]byte, error)) (Pipeline, []Issue) {
38 p, issues, err := parseBytes(data, read, nil)
39 p, issues, err := parseBytes(data, read, nil)
39 if err != nil {
40 if err != nil {
40 issues = append([]Issue{{Line: 1, Key: "ci.err.yaml", Args: []any{err.Error()}}}, issues...)
41 // parseBytes verpakt een YAML-fout al als ci.err.yaml. Nog eens
42 // verpakken geeft "invalid YAML: invalid YAML: ...".
43 line := Issue{Line: 1, Key: "ci.err.yaml", Args: []any{err.Error()}}
44 var ie i18n.Error
45 if errors.As(err, &ie) {
46 line.Key, line.Args = ie.Key, ie.Args
47 }
48 issues = append([]Issue{line}, issues...)
41 }
49 }
42 return p, issues
50 return p, issues
43}
51}
internal/server/editor_test.go +1 −1
@@ -97,7 +97,7 @@ func TestPipelineEditorAndProtectedBranch(t *testing.T) {
97 97 if err := json.Unmarshal([]byte(raw), &lint); err != nil {
98 98 t.Fatalf("lint json: %v\n%s", err, raw)
99 99 }
100 if lint.StatusClass != "failed" || len(lint.Issues) == 0 || !strings.Contains(lint.Issues[0].Text, "invalid YAML") {
100 if lint.StatusClass != "failed" || len(lint.Issues) == 0 || strings.Count(lint.Issues[0].Text, "invalid YAML") != 1 {
101 101 t.Fatalf("lint: %+v", lint)
102 102 }
103 103
@@ -97,7 +97,7 @@ func TestPipelineEditorAndProtectedBranch(t *testing.T) {
97 if err := json.Unmarshal([]byte(raw), &lint); err != nil {
97 if err := json.Unmarshal([]byte(raw), &lint); err != nil {
98 t.Fatalf("lint json: %v\n%s", err, raw)
98 t.Fatalf("lint json: %v\n%s", err, raw)
99 }
99 }
100 if lint.StatusClass != "failed" || len(lint.Issues) == 0 || !strings.Contains(lint.Issues[0].Text, "invalid YAML") {
100 if lint.StatusClass != "failed" || len(lint.Issues) == 0 || strings.Count(lint.Issues[0].Text, "invalid YAML") != 1 {
101 t.Fatalf("lint: %+v", lint)
101 t.Fatalf("lint: %+v", lint)
102 }
102 }
103
103