Skip to content

Improve YAML syntax error quality: translations + precise engine field location#18434

Closed
Copilot wants to merge 3 commits intomainfrom
copilot/improve-yaml-error-messages
Closed

Improve YAML syntax error quality: translations + precise engine field location#18434
Copilot wants to merge 3 commits intomainfrom
copilot/improve-yaml-error-messages

Conversation

Copy link
Contributor

Copilot AI commented Feb 26, 2026

The daily syntax error quality check scored YAML parse errors at 44/100 — raw goccy parser jargon surfaced directly with no plain-English translation or source guidance. Engine validation errors also reported file:1:1 instead of pointing to the actual engine: field.

Changes

Parser-level YAML error translation (pkg/parser/yaml_error.go)

Added yamlParserMessageTranslations (10 entries) and translateYAMLFormattedOutput(), called inside FormatYAMLError() after goccy formats the output. Translations replace the message text in-place; source context lines and ^ pointer are preserved.

Before: [3:1] mapping value is not allowed in this context
After:  [3:1] Invalid YAML syntax: unexpected ':' — check indentation or key syntax

Workflow-level translation coverage (pkg/workflow/frontmatter_error.go)

Expanded yamlErrorTranslations with actual goccy v1.19.2 patterns: singular "mapping value is not allowed in this context", "unexpected key name", tab-related errors (found character '\t' that cannot start any token), "block sequence entries are not allowed", unclosed bracket/quote errors. Legacy plural form retained for backward compat.

Precise engine field location (pkg/workflow/compiler_orchestrator_engine.go)

On validateEngine failure, uses parser.LocateJSONPathInYAML(frontmatterYAML, "/engine") to find the engine field position, then calls formatCompilerErrorWithPosition with the document-adjusted line/column.

Before: workflow.md:1:1: error: invalid engine: copilot-experimental...
After:  workflow.md:3:9: error: invalid engine: copilot-experimental...

Test updates

  • Updated TestFrontmatterSyntaxErrors, TestCompileWorkflowWithInvalidYAML, TestYAMLFormatErrorOutput, and TestParseWorkflowFile_ErrorPropagation to assert translated messages rather than raw goccy strings
  • Added TestFormatYAMLErrorTranslations (parser package) and TestSetupEngineAndImports_InvalidEngine_HasPreciseLocation (workflow package)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw GO111MODULE 64/bin/go git conf�� --get remote.origin.url /usr/bin/git 8abG/QuG4b8H4fzBgit GO111MODULE 64/bin/go git (http block)
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw remote.origin.urinit /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel sh /usr/bin/git git (http block)
    • Triggering command: /usr/bin/gh /usr/bin/gh api graphql -f query=query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { hasDiscussionsEnabled } } -f owner=github -f name=gh-aw e/git /usr/bin/git git _out�� --show-toplevel git /usr/bin/git --show-toplevel git 1/x64/bin/node git (http block)
  • https://api.github.com/repos/actions/ai-inference/git/ref/tags/v1
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha -json GO111MODULE 473280/b368/vet.cfg GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE ache/node/24.13.1/x64/bin/node GOINSECURE GOMOD GOMODCACHE /tmp/go-build416473280/b001/gh-aw.test (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha --show-toplevel go /usr/bin/sed -json l /opt/hostedtoolc--show-toplevel sed s/-\�� GOMODCACHE go /usr/bin/git -json GO111MODULE ache/node/24.13.--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/ai-inference/git/ref/tags/v1 --jq .object.sha /usr/bin/gcc 64/pkg/tool/linux_amd64/link 1/x64/bin/node kflow.test gcc ortcfg.link git arne�� --show-toplevel XMW3V9VA4kd3KN6poE/Roh3Pu9sdqa7h5HSbLIJ/6R7DJaGgRoyZGsPZcwsu 1/x64/bin/node --show-toplevel e/git g_.a git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v3
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha -json GO111MODULE ache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE cfg GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha --show-toplevel 64/pkg/tool/linu-importcfg /usr/bin/git -json GO111MODULE ache/go/1.25.0/x--show-toplevel git rev-�� --show-toplevel go /usr/bin/git 1005-31465/test-git GO111MODULE ache/go/1.25.0/x--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v3 --jq .object.sha Actor: ${{ github.actor }} git /usr/bin/git --show-toplevel go x_amd64/asm git rev-�� --show-toplevel x_amd64/asm /opt/hostedtoolcache/node/24.13.1/x64/bin/npm 40\} ature-branch.patrev-parse /usr/bin/git /opt/hostedtoolcache/node/24.13.1/x64/bin/npm (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v4 --jq .object.sha ithub/workflows/agent-persona-ex-errorsas 473280/b125/vet.cfg ache/node/24.13.1/x64/bin/node GOINSECURE GOMOD GOMODCACHE go t-38�� sistency_GoAndJavaScript2398319075/001/test-empty-frontmatter.md GO111MODULE /opt/hostedtoolcache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v4 --jq .object.sha -json GO111MODULE ache/node/24.13.1/x64/bin/node GOINSECURE GOMOD GOMODCACHE go t-34�� 1005-31465/test-3486783250 GO111MODULE ache/node/24.13.1/x64/bin/node GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v4 --jq .object.sha --get remote.origin.url /usr/bin/git k/gh-aw/gh-aw/pkgit k/gh-aw/gh-aw/pkrev-parse 64/bin/go git rev-�� --show-toplevel /opt/hostedtoolcconfig /usr/bin/git b/workflows -trimpath 64/bin/go git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v5
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env 3407421921 GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha k/gh-aw/gh-aw/.github/workflows/ai-moderator.md -buildtags e/git -errorsas -ifaceassert -nilfunc e/git -tes�� -test.paniconexit0 -test.v=true /usr/bin/git -test.timeout=10git -test.run=^Test -test.short=true--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha 64/bin/go node /usr/bin/git --check scripts/**/*.js 64/bin/go git rev-�� --show-toplevel go /usr/bin/gh -json GO111MODULE 64/bin/go gh (http block)
  • https://api.github.com/repos/actions/github-script/git/ref/tags/v8
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha GOSUMDB GOWORK 64/bin/go GOINSECURE GOMOD GOMODCACHE go env e=false GO111MODULE 64/bin/go GOINSECURE %H %ct %D 29e16c8b80af5e46-json go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE sh (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha d GO111MODULE 64/bin/go GOINSECURE b/gh-aw/pkg/loggenv GOMODCACHE go env QcDs/RccYqQqTSKBGOINSECURE GO111MODULE 64/bin/go GOINSECURE GOMOD run-script/lib/n--show-toplevel 864396/b393/impoGOPROXY (http block)
  • https://api.github.com/repos/actions/setup-go/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha 473280/b001/_pkg_.a GO111MODULE 1/x64/bin/node GOINSECURE GOMOD GOMODCACHE 1/x64/bin/node env xloq/PUScdUXa027miiVrxloq GO111MODULE /opt/hostedtoolcache/go/1.25.0/x64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha 8/001/test-simple-frontmatter.md ache/go/1.25.0/x64/pkg/tool/linux_amd64/compile /usr/bin/find /test1.md /test2.lock.yml 473280/b372=> find /tmp�� -maxdepth 4 /usr/bin/git d -name bin git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-go/git/ref/tags/v4 --jq .object.sha --show-toplevel git /usr/bin/sed --show-toplevel 1/x64/bin/node /usr/lib/git-cor--show-toplevel sed s|[/�� 473280/b406/vet.--show-toplevel /usr/lib/git-core/git 1/x64/bin/node run --auto /usr/bin/git git (http block)
  • https://api.github.com/repos/actions/setup-node/git/ref/tags/v4
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha g/stringutil/ansi.go g/stringutil/identifiers.go ache/node/24.13.1/x64/bin/node GOINSECURE GOMOD GOMODCACHE go t-30�� sistency_GoAndJavaScript2398319075/001/test-empty-frontmatter.md GO111MODULE 473280/b285/vet.cfg GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha --show-toplevel rtcfg /usr/bin/bash g/styles/theme.ggit g/styles/theme_trev-parse ache/node/24.13.--show-toplevel bash -c 6393/001/stability-test.md go /usr/bin/git sistency_GoAndJagit GO111MODULE /opt/hostedtoolc--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/setup-node/git/ref/tags/v4 --jq .object.sha --show-toplevel git /usr/bin/git --show-toplevel 2c57Qly0mPz2q/Bxrev-parse /usr/bin/git git bran�� --show-current git 1/x64/bin/node github.actor }} git go /usr/bin/git git (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/1/artifacts
    • Triggering command: /usr/bin/gh gh run download 1 --dir test-logs/run-1 GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go stlo�� -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12345/artifacts
    • Triggering command: /usr/bin/gh gh run download 12345 --dir test-logs/run-12345 GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/12346/artifacts
    • Triggering command: /usr/bin/gh gh run download 12346 --dir test-logs/run-12346 GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/2/artifacts
    • Triggering command: /usr/bin/gh gh run download 2 --dir test-logs/run-2 GO111MODULE x_amd64/link GOINSECURE GOMOD GOMODCACHE x_amd64/link env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE cv/MHVXTljsf_VqJ8GTpmj5/2S6Z_Ip2rev-parse (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/3/artifacts
    • Triggering command: /usr/bin/gh gh run download 3 --dir test-logs/run-3 GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/4/artifacts
    • Triggering command: /usr/bin/gh gh run download 4 --dir test-logs/run-4 GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/runs/5/artifacts
    • Triggering command: /usr/bin/gh gh run download 5 --dir test-logs/run-5 GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path GOSUMDB GOWORK 64/bin/go GOINSECURE GOMOD erignore ache/go/1.25.0/xGO111MODULE env 864396/b397/_pkgGOINSECURE GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 100 GOMOD GOMODCACHE sh -c "prettier" --cheGOSUMDB GOPROXY 64/bin/go GOSUMDB GOWORK 64/bin/go node (http block)
    • Triggering command: /usr/bin/gh gh run list --json databaseId,number,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,displayTitle --workflow nonexistent-workflow-12345 --limit 6 GOMOD GOMODCACHE go env es.md GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env 795860437/.github/workflows GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha xterm-color go 1/x64/bin/npm -json GO111MODULE 64/bin/go 1/x64/bin/npm rev-�� --show-toplevel go /usr/bin/git -json GO111MODULE 64/bin/go git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.0.0 --jq .object.sha --show-toplevel git /usr/bin/git --show-toplevel x_amd64/compile /usr/bin/git git rev-�� --show-toplevel git ache/go/1.25.0/x64/bin/node --show-toplevel go /usr/bin/git git (http block)
  • https://api.github.com/repos/nonexistent/action/git/ref/tags/v999.999.999
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go env 75/001/test-complex-frontmatter-with-tools.md GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha list --json /usr/bin/git --workflow nonexistent-workrev-parse --limit git 1/x6�� --show-toplevel go /usr/bin/git hub/workflows GO111MODULE 64/bin/go git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/nonexistent/action/git/ref/tags/v999.999.999 --jq .object.sha --show-toplevel git /usr/bin/git image:v1.0.0 go /usr/bin/git git rev-�� --show-toplevel git /usr/bin/git --show-toplevel go /usr/bin/git git (http block)
  • https://api.github.com/repos/nonexistent/repo/actions/runs/12345
    • Triggering command: /usr/bin/gh gh run view 12345 --repo nonexistent/repo --json status,conclusion GOINSECURE GOMOD GOMODCACHE go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/owner/repo/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo 64/bin/go GOINSECURE GOMOD erignore ache/go/1.25.0/xGO111MODULE env 864396/b404/_pkgGOINSECURE GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path --repo owner/repo 64/bin/go GOINSECURE GOMOD erignore ache/go/1.25.0/xGO111MODULE env 864396/b410/_pkgGOINSECURE GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/owner/repo/contents/file.md
    • Triggering command: /tmp/go-build416473280/b381/cli.test /tmp/go-build416473280/b381/cli.test -test.testlogfile=/tmp/go-build416473280/b381/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true GOINSECURE GOMOD GOMODCACHE go m/_n�� -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (http block)
  • https://api.github.com/repos/test-owner/test-repo/actions/secrets
    • Triggering command: /usr/bin/gh gh api /repos/test-owner/test-repo/actions/secrets --jq .secrets[].name GOSUMDB GOWORK 64/bin/go GOINSECURE GOMOD erignore ache/go/1.25.0/xGO111MODULE env 864396/b385/_pkgGOINSECURE GO111MODULE 64/bin/go GOINSECURE b/gh-aw/pkg/consenv GOMODCACHE go (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>[syntax-error-quality] Error Message Quality: YAML Syntax Errors Need Improvement</issue_title>
<issue_description>### 📊 Error Message Quality Analysis

Analysis Date: 2025-07-23
Test Cases: 3
Average Score: 66.7/100
Status: ⚠️ Needs Improvement


Executive Summary

Static analysis of the compiler error pipeline was used to reconstruct the error messages produced for three representative error types. YAML syntax errors score critically low (44/100), falling below the per-test threshold of 55, due to raw parser output being surfaced without plain-English translation or fix guidance. Engine validation errors (74/100) and schema constraint errors (82/100) are much stronger but have minor consistency issues. The average score of 66.7/100 falls below the 70/100 threshold, and one test case is in the critical range, triggering this issue.

Key Findings:

  • Strengths: Schema errors (Test 3) have excellent source context rendering; engine errors have "Did you mean" suggestions and documentation links; schema constraint messages are translated to plain English
  • ⚠️ Weaknesses: YAML parse errors surface raw goccy jargon without translation; engine errors are attributed to file:1:1 instead of the actual engine: field location; engine errors leak the internal "failed to generate YAML" prefix
  • Critical Issue: YAML syntax errors provide no actionable fix guidance — no "Correct usage:" example, no suggestion, no translated message

Test Case Results

Test Case 1: Invalid YAML Syntax — Score: 44/100 ❌ Critical

Test Configuration

Workflow: dependabot-burner.md (22 lines, simple)
Error Type: Category A — Frontmatter YAML syntax error
Error Introduced: Line 2: on weekly (missing colon — should be on: weekly)

Reconstructed Compiler Output

The compiler calls yaml.Unmarshal() in pkg/parser/frontmatter_content.go, which fails and is passed to FormatYAMLError(). The goccy formatted output is then wrapped as-is via formatCompilerError(markdownPath, "error", err.Error(), err):

test-1-err.md:1:1: error: failed to parse frontmatter:
[2:9] string was used where mapping is expected
>  2 | on weekly
         ^
```

*(The goccy source pointer is present, but the outer position is stuck at 1:1 and the message is raw parser jargon.)*

#### Evaluation Scores

| Dimension | Score | Rating |
|-----------|-------|--------|
| Clarity | 12/25 | Poor |
| Actionability | 8/25 | Poor |
| Context | 13/20 | Acceptable |
| Examples | 2/15 | Critical |
| Consistency | 9/15 | Acceptable |
| **Total** | **44/100** | **Critical ❌** |

#### Strengths
- ✅ `goccy/go-yaml` renders the problematic source line with a `^` pointer
- ✅ The source line `on weekly` is visible so a developer can spot the issue

#### Weaknesses
- ❌ "string was used where mapping is expected" is raw YAML parser jargon — opaque to developers unfamiliar with the YAML spec
- ❌ No suggestion of the correct syntax (`on: weekly`)
- ❌ No "Did you mean:" hint or "Correct usage:" example
- ❌ Outer file position is `1:1` — imprecise since `goccy` already knows the exact line
- ❌ No documentation link
- ❌ "failed to parse frontmatter:" prefix is accurate but adds no actionable context

#### Improvement Suggestions

1. **Translate common goccy YAML error messages to plain English** (highest impact):
   ```
   Current:  "string was used where mapping is expected"
   Better:   "Missing ':' after key 'on' — expected a key: value pair"
   ```

2. **Add "Correct usage:" example for common YAML mistakes**:
   ```
   Correct usage:
     on: weekly
   ```

3. **Propagate goccy's line/column into the outer `formatCompilerError` call** so `file:line:col` is accurate:
   ```go
   // In pkg/parser/frontmatter_content.go, extract line from goccy error
   // and call formatCompilerErrorWithPosition(markdownPath, actualLine, actualCol, ...)
   ```

4. **Shared "Did you mean" pattern** already used in engine validation — apply the same pattern for field names

</details>

<details>
<summary><b>Test Case 2: Invalid Engine Name</b> — Score: 74/100 ✅ Good</summary>

#### Test Configuration

**Workflow**: `issue-triage-agent.md` (88 lines, medium)
**Error Type**: Category B — Configuration error
**Error Introduced**: `engine: copiilot` (typo — should be `engine: copilot`)

#### Reconstructed Compiler Output

Engine validation in `pkg/workflow/engine_validation.go` produces an excellent message, but it's wrapped by `generateAndValidateYAML()` with a noisy prefix:

```
test-2-err.md:1:1: error: failed to generate YAML: invalid engine: copiilot.
Valid engines are: copilot, claude, codex, custom.

Did you mean: copilot?

Example:
  engine: copilot

See: https://github.com/github/gh-aw/blob/main/README.md#engines
```

#### Evaluation Scores

| Dimension | Score | Rating |
|-----------|-------|-----...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes github/gh-aw#18392

<!-- START COPILOT CODING AGENT TIPS -->
---

🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. [Learn more about Advanced Security.](https://gh.io/cca-advanced-security)

Copilot AI and others added 2 commits February 26, 2026 02:56
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
…, test updates

- pkg/parser/yaml_error.go: Add yamlParserMessageTranslations and translateYAMLFormattedOutput() to translate raw goccy messages in FormatYAMLError()
- pkg/workflow/frontmatter_error.go: Add missing translations for actual goccy v1.19 error patterns
- pkg/workflow/compiler_orchestrator_engine.go: Use LocateJSONPathInYAML to emit precise file:line:col for engine validation errors
- Tests: Update to check translated messages; add TestFormatYAMLErrorTranslations and TestSetupEngineAndImports_InvalidEngine_HasPreciseLocation"

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Improve quality of YAML syntax error messages Improve YAML syntax error quality: translations + precise engine field location Feb 26, 2026
@pelikhan pelikhan marked this pull request as ready for review February 26, 2026 03:44
Copilot AI review requested due to automatic review settings February 26, 2026 03:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request improves YAML syntax error quality by adding user-friendly translations for raw goccy parser messages and providing precise source locations for engine validation errors, addressing a quality score that was at 44/100.

Changes:

  • Added parser-level YAML error message translations (10 entries) that convert raw goccy jargon to plain English while preserving source context
  • Expanded workflow-level translation coverage with actual goccy v1.19.2 patterns including singular/plural forms and legacy patterns for backward compatibility
  • Implemented precise engine field location reporting using LocateJSONPathInYAML instead of defaulting to file:1:1
  • Updated all affected tests to assert translated messages rather than raw goccy error strings
  • Added new tests for translation functionality and precise engine location reporting

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pkg/parser/yaml_error.go Added yamlParserMessageTranslations table (10 entries) and translateYAMLFormattedOutput() function to translate raw goccy messages to user-friendly plain English
pkg/workflow/frontmatter_error.go Expanded yamlErrorTranslations with actual goccy v1.19.2 patterns including tab errors, unclosed brackets/quotes, and block sequence errors
pkg/workflow/compiler_orchestrator_engine.go Added precise engine field location using LocateJSONPathInYAML to report errors at the actual engine field line/column instead of file:1:1
pkg/parser/yaml_error_test.go Added TestFormatYAMLErrorTranslations to verify translations work correctly while preserving source context
pkg/workflow/compiler_orchestrator_engine_test.go Added TestSetupEngineAndImports_InvalidEngine_HasPreciseLocation and updated existing test to verify precise location reporting
pkg/workflow/yaml_message_translation_test.go Added tests for new translation patterns (singular "mapping value", "unexpected key name", tab errors, block sequence, unclosed brackets)
pkg/parser/frontmatter_syntax_errors_test.go Updated test assertions to expect translated messages ("Invalid YAML syntax", "unclosed") instead of raw goccy strings
pkg/workflow/compiler_yaml_test.go Updated test assertions to expect "Invalid YAML syntax" and "unclosed" instead of raw goccy messages
pkg/workflow/compiler_orchestrator_workflow_test.go Updated to expect "unclosed bracket" translation instead of raw "sequence end token" message
pkg/workflow/data/action_pins.json Added SHA pin for anchore/sbom-action@v0 (used in release workflow)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +113 to +117
"anchore/sbom-action@v0": {
"repo": "anchore/sbom-action",
"version": "v0",
"sha": "17ae1740179002c89186b61233e0f892c3118b11"
},
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated change: This addition of anchore/sbom-action@v0 to the action pins appears unrelated to the stated PR objective of improving YAML syntax error quality. The PR description focuses on error message translations and precise engine field location, but doesn't mention updating action pins.

If this change is necessary (e.g., to support a workflow that uses this action in tests), it should be explained in the PR description. Otherwise, consider removing it to keep the PR focused on a single concern.

Copilot uses AI. Check for mistakes.
Comment on lines 23 to 85
var yamlErrorTranslations = []struct {
pattern string
translation string
}{
// Colon in wrong context (actual goccy v1.19 message uses singular "value")
{
"non-map value is specified",
"Invalid YAML syntax: expected 'key: value' format (did you forget a colon after the key?)",
"mapping value is not allowed in this context",
"Invalid YAML syntax: unexpected ':' — check indentation or key syntax",
},
// Legacy plural form kept for tests and older goccy versions
{
"mapping values are not allowed",
"Invalid YAML syntax: unexpected ':' — check your indentation",
},
// Bare key without colon OR list item in mapping context
{
"non-map value is specified",
"Invalid YAML syntax: expected 'key: value' format (did you forget a colon after the key?)",
},
// Plain word without colon (e.g. "engine copilot")
{
"unexpected key name",
"Invalid YAML syntax: expected 'key: value' format (did you forget a colon after the key?)",
},
// Generic "did not find expected" catch-all (kept for backward compatibility)
{
"did not find expected",
"Invalid YAML syntax: check indentation or missing key",
},
// Tab character errors; goccy v1.19 uses an actual tab char (0x09) inside single quotes
{
"found a tab character where an indentation space is expected",
"Invalid YAML syntax: use spaces for indentation, not tabs",
},
{
"tab character cannot use as a map key",
"Invalid YAML syntax: use spaces for indentation, not tabs",
},
// The full goccy message uses an actual tab character (0x09) inside single quotes
{
"found character '\t' that cannot start any token",
"Invalid YAML syntax: use spaces for indentation, not tabs",
},
// List item '-' in wrong context
{
"block sequence entries are not allowed",
"Invalid YAML syntax: unexpected list item '-' — check indentation",
},
// Unclosed sequences/brackets
{
"sequence end token ']' not found",
"Invalid YAML syntax: unclosed bracket — add ']' to close the list",
},
// Unclosed string quotes
{
"could not find end character of double-quoted text",
`Invalid YAML syntax: unclosed double quote — add '"' to close the string`,
},
{
"could not find end character of single-quoted text",
"Invalid YAML syntax: unclosed single quote — add \"'\" to close the string",
},
}
Copy link

Copilot AI Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential redundancy with parser-level translations: The yamlErrorTranslations table in this file duplicates most entries from yamlParserMessageTranslations in pkg/parser/yaml_error.go.

Since the parser package's FormatYAMLError already translates all YAML errors before they reach the workflow package's createFrontmatterError function (which applies translateYAMLMessage at line 120), these workflow-level translations may never match because the raw patterns have already been replaced.

Consider consolidating to a single translation table in a shared location, or documenting why two separate translation layers are needed if there's a specific reason for the current architecture.

Copilot uses AI. Check for mistakes.
@pelikhan pelikhan closed this Feb 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants