tenseleyflow/shithub / 8fb3ad4

Browse files

actions/workflow: pin bracket-quoted diagnostic path for non-ident env keys (S41a-L6)

Authored by mfwolffe <wolffemf@dukes.jmu.edu>
SHA
8fb3ad40656b9423782ffd99593774394497c1ee
Parents
5dacf0e
Tree
faf8ccc

1 changed file

StatusFile+-
M internal/actions/workflow/parse_test.go 33 0
internal/actions/workflow/parse_test.gomodified
@@ -386,3 +386,36 @@ jobs:
386386
 		t.Fatalf("expected boolean-error diagnostic for 'yes', got: %v", diags)
387387
 	}
388388
 }
389
+
390
+// TestParse_DiagnosticPathQuotesNonIdentKeys pins L6: env keys that
391
+// contain dots, spaces, etc. produce bracket-quoted diagnostic paths
392
+// instead of ambiguous concat. Compare:
393
+//   - identifier-shaped key: path is `jobs.j.env.GOOD`
394
+//   - dotted key: path is `jobs.j.env["weird.key"]` (unambiguous)
395
+func TestParse_DiagnosticPathQuotesNonIdentKeys(t *testing.T) {
396
+	t.Parallel()
397
+	src := []byte(`name: x
398
+on: push
399
+jobs:
400
+  j:
401
+    runs-on: ubuntu-latest
402
+    env:
403
+      "weird.key":
404
+        nested: not-a-scalar
405
+    steps:
406
+      - run: echo
407
+`)
408
+	_, diags, err := workflow.Parse(src)
409
+	if err != nil {
410
+		t.Fatalf("parse: %v", err)
411
+	}
412
+	found := false
413
+	for _, d := range diags {
414
+		if strings.Contains(d.Path, `["weird.key"]`) {
415
+			found = true
416
+		}
417
+	}
418
+	if !found {
419
+		t.Fatalf("expected bracket-quoted path for dotted env key, got diags: %v", diags)
420
+	}
421
+}