Skip to content

Fix double-wrapped compiler errors emitting spurious file:1:1: prefix#24316

Merged
pelikhan merged 2 commits intomainfrom
copilot/fix-compiler-error-messages-formatting
Apr 3, 2026
Merged

Fix double-wrapped compiler errors emitting spurious file:1:1: prefix#24316
pelikhan merged 2 commits intomainfrom
copilot/fix-compiler-error-messages-formatting

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 3, 2026

All compiler errors were being double-formatted: the inner message already contained the correct file:line:col: location, but compiler.go wrapped it again with a file:1:1: error: prefix because isFormattedCompilerError() only recognises *wrappedCompilerError and *parser.FormattedParserError — not the plain errors.New/fmt.Errorf values returned by the two offending paths.

Root cause

  • pkg/parser/schema_compiler.go (validateWithSchemaAndLocation) — returned errors.New(formattedErr) after building a fully-formatted console.CompilerError string
  • pkg/workflow/frontmatter_error.go (createFrontmatterError) — returned fmt.Errorf("%s\n%s", vscodeFormat, context) for already-formatted YAML errors

Both evaded the isFormattedCompilerError check, triggering a second wrap at file:1:1.

Changes

  • pkg/parser/schema_compiler.go — replace both errors.New(formattedErr) returns with &FormattedParserError{formatted: formattedErr} (same package, direct field access)
  • pkg/parser/import_error.go — add NewFormattedParserError(formatted string) constructor for use by external packages
  • pkg/workflow/frontmatter_error.go — replace fmt.Errorf(...) on the pre-formatted YAML paths with parser.NewFormattedParserError(...)
  • pkg/workflow/compiler_error_formatter_test.go — add coverage for the NewFormattedParserError path
// Before — evades isFormattedCompilerError, gets re-wrapped as file:1:1: error:
return errors.New(formattedErr)

// After — detected by isFormattedCompilerError, passed through unchanged
return &FormattedParserError{formatted: formattedErr}

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 wAClDFTbl ache/go/1.25.0/x--show-toplevel git rev-�� --show-toplevel ache/go/1.25.0/x^remote\..*\.gh-resolved$ /usr/bin/git W8maOFAUC GO111MODULE ache/go/1.25.0/x--show-toplevel git (http block)
  • https://api.github.com/orgs/test-owner/actions/secrets
    • Triggering command: /usr/bin/gh gh api /orgs/test-owner/actions/secrets --jq .secrets[].name -json GOMOD 64/bin/go tierignore **/*.cjs 64/bin/go go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE go (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 --show-toplevel x_amd64/compile /usr/bin/git lex-frontmatter-git o x_amd64/compile git rev-�� --show-toplevel x_amd64/compile /usr/bin/git -json GO111MODULE 64/pkg/tool/linu--show-toplevel /usr/bin/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 /tmp/go-build2159458216/b396/_pkg_.a -trimpath /usr/bin/infocmp -p main -lang=go1.25 infocmp -1 ithub-script/git/ref/tags/v8 -dwarf=false /opt/hostedtoolcache/node/24.14.0/x64/bin/node 97224233/001' 97224233/001' -nolocalimports node (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 g_.a GO111MODULE 64/pkg/tool/linux_amd64/vet GOINSECURE a20 64/src/internal/--show-toplevel 64/pkg/tool/linux_amd64/vet env lidations passed" uLao4T9cM ache/go/1.25.0/x64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE ache/go/1.25.0/x64/pkg/tool/linuTest User (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha --show-toplevel 64/pkg/tool/linurev-parse /usr/bin/git -json GO111MODULE x_amd64/vet git rev-�� --show-toplevel x_amd64/vet /usr/bin/git g_.a @v1.1.3/cpu/cpu.rev-parse 64/pkg/tool/linu--show-toplevel git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v5 --jq .object.sha --show-toplevel ache/go/1.25.0/x64/pkg/tool/linuremote.origin.url /usr/bin/git 8852254/b237/_pkgit 87yA/ldQFu9Xepr_rev-parse 8852254/b237=> git rev-�� --show-toplevel /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linuTest User /usr/bin/git lS-N/5jKyiZv1zwXgit -trimpath /opt/hostedtoolc--show-toplevel git (http block)
  • https://api.github.com/repos/actions/checkout/git/ref/tags/v6
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha --get remote.origin.url /usr/bin/git -json GO111MODULE x_amd64/compile git -C /tmp/gh-aw-test-runs/20260403-135741-31501/test-95929960 rev-parse /usr/bin/git @{u} Gitbranch_with_hrev-parse x_amd64/compile git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha /home/REDACTED/work/gh-aw/gh-aw/.github/workflows/agent-persona-explorer.md go r,url,status,conclusion,workflowName,createdAt,startedAt,updatedAt,event,headBranch,headSha,disp--show-toplevel -json flow x_amd64/compile git rev-�� 0:00Z x_amd64/compile /usr/bin/git -json GO111MODULE x_amd64/compile git (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/checkout/git/ref/tags/v6 --jq .object.sha --show-toplevel ache/go/1.25.0/x64/pkg/tool/linux_amd64/compile /usr/bin/git 8852254/b089/_pkgit d/gh-aw-wasm/mairev-parse .cfg git rev-�� --show-toplevel ache/go/1.25.0/x64/pkg/tool/linux_amd64/link /usr/bin/git -json W94_/e_Qf3Rdg4GCrev-parse ache/go/1.25.0/x--show-toplevel git (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 -goversion go1.25.0 -c=4 -nolocalimports -importcfg /tmp/go-build1788852254/b205/importcfg -pack -o /tmp/go-build388-p o 64/bin/go -p github.com/githu-o -lang=go1.25 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 x_amd64/asm GOINSECURE GOMOD GOMODCACHE x_amd64/asm (http block)
    • Triggering command: /usr/bin/gh gh api /repos/actions/github-script/git/ref/tags/v8 --jq .object.sha -json GO111MODULE 11fa3bf9a6309ba9-d GOINSECURE GOMOD GOMODCACHE go env sm-opt -Oz (size-errorsas GO111MODULE x_amd64/asm GOINSECURE GOMOD GOMODCACHE x_amd64/asm (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 --get remote.origin.url /usr/lib/git-core/git -dirty" -o gh-awgit GO111MODULE x_amd64/compile /usr/lib/git-core/git main�� run --auto /usr/bin/git --detach GO111MODULE x_amd64/compile 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 GOMODCACHE go /usr/bin/git -json GO111MODULE x_amd64/asm git comm�� -m Add workflow /usr/bin/git -json GO111MODULE x_amd64/compile git (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v0.1.2
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v0.1.2 --jq .object.sha GOMODCACHE go /usr/lib/git-core/git -json GO111MODULE x_amd64/compile /usr/lib/git-core/git main�� run --auto /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet --detach GO111MODULE x_amd64/compile /opt/hostedtoolcache/go/1.25.0/x64/pkg/tool/linux_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.0.0 --jq .object.sha /tmp/go-build1788852254/b129/_pkg_.a -trimpath /opt/hostedtoolcache/go/1.25.0/x64/bin/go -p math/big -lang=go1.25 go env runs/20260403-135741-31501/test-2293527662/.github/workflows -dwarf=false /usr/bin/git l -symabis /tmp/go-build178--show-toplevel git (http block)
  • https://api.github.com/repos/github/gh-aw-actions/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw-actions/git/ref/tags/v1.2.3 --jq .object.sha runs/20260403-135741-31501/test-3449930400/.github/workflows -trimpath /usr/bin/cut l /tmp/go-build178rev-parse -I cut -f1 GOOS_js -D ache/node/24.14.0/x64/bin/node -gensymabis -o /tmp/go-build178--show-toplevel /bin/sh (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/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linuremote.origin.url env g_.a 0/internal/language/compact/compact.go 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linutest@example.com (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 g_.a oding@v0.5.4/json/codec.go 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_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/pkg/tool/linux_amd64/asm GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/asm estl�� -json oding@v0.5.4/ascii/equal_fold.go 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile (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 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linuorigin env 88/001/test-simple-frontmatter.mremote.origin.url rotocol/go-sdk@v1.4.1/internal/j-c=4 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile (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/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile env g_.a FtlqRiP0t 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile (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 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linuremote.origin.url env g_.a GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD abis 64/pkg/tool/linux_amd64/compile (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 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linuorigin env g_.a GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD abis 64/pkg/tool/linux_amd64/compile (http block)
  • https://api.github.com/repos/github/gh-aw/actions/workflows
    • Triggering command: /usr/bin/gh gh workflow list --json name,state,path 197224233/001' 197224233/001' 64/bin/go -d **/*.cjs 64/bin/go go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD e_wasm.s 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 x_amd64/compile env -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (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 x_amd64/vet env g_.a GO111MODULE 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v0.47.4
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v0.47.4 --jq .object.sha --show-toplevel 64/pkg/tool/linux_amd64/asm /usr/bin/git -json GO111MODULE 64/pkg/tool/linu--show-toplevel git rev-�� --show-toplevel 64/pkg/tool/linux_amd64/compile /usr/bin/git g_.a GO111MODULE 64/pkg/tool/linu--verify git (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 ility-kit.md GO111MODULE x_amd64/compile GOINSECURE go-sdk/oauthex GOMODCACHE x_amd64/compile env g_.a GO111MODULE x_amd64/vet GOINSECURE GOMOD GOMODCACHE x_amd64/vet (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v1.2.3
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v1.2.3 --jq .object.sha -json 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/git/ref/tags/v2.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile env -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v2.0.0 --jq .object.sha -json GO111MODULE x_amd64/asm GOINSECURE GOMOD GOMODCACHE x_amd64/asm env Gitmain_branch11-test.timeout=10m0s Gitmain_branch11-test.run=^Test x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (http block)
  • https://api.github.com/repos/github/gh-aw/git/ref/tags/v3.0.0
    • Triggering command: /usr/bin/gh gh api /repos/github/gh-aw/git/ref/tags/v3.0.0 --jq .object.sha -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile _bra�� -json GO111MODULE x_amd64/compile GOINSECURE GOMOD GOMODCACHE x_amd64/compile (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 mLsRemoteWithRealGitcustom_branch1126022454/001' mLsRemoteWithRealGitcustom_branch1126022454/001' 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile env y_with_repos_array_c413552337/001 aCCuGrWJu 64/pkg/tool/linux_amd64/vet GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/vet (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 64/pkg/tool/linux_amd64/compile env g_.a o 64/pkg/tool/linux_amd64/compile GOINSECURE GOMOD GOMODCACHE 64/pkg/tool/linux_amd64/compile (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 -d 8bd1242156872eea-o 64/bin/go go env -json 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 --write **/*.cjs 64/bin/go go env -json GO111MODULE 64/bin/go GOINSECURE GOMOD GOMODCACHE y.s (http block)
  • https://api.github.com/repos/owner/repo/contents/file.md
    • Triggering command: /tmp/go-build2159458216/b396/cli.test /tmp/go-build2159458216/b396/cli.test -test.testlogfile=/tmp/go-build2159458216/b396/testlog.txt -test.paniconexit0 -test.v=true -test.parallel=4 -test.timeout=10m0s -test.run=^Test -test.short=true -nolocalimports -importcfg /tmp/go-build1788852254/b210/importcfg -pack list�� -e -f 64/bin/go -- unsafe 64/bin/go 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 GOPATH=$(go env -I (http block)

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

- pkg/parser/schema_compiler.go: return &FormattedParserError{} instead of
  errors.New() so isFormattedCompilerError() recognises them and compiler.go
  does not re-wrap with a spurious file:1:1: error: prefix
- pkg/parser/import_error.go: add NewFormattedParserError constructor for
  external packages to create FormattedParserError values
- pkg/workflow/frontmatter_error.go: return parser.NewFormattedParserError()
  for pre-formatted YAML error strings instead of fmt.Errorf()
- pkg/workflow/compiler_error_formatter_test.go: cover NewFormattedParserError path

Fixes #<issue> — compiler error messages double-format with wrong line number

Agent-Logs-Url: https://github.com/github/gh-aw/sessions/a25ffcf4-a170-4618-8c25-3837826bef98

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix compiler error messages double-format with wrong line number Fix double-wrapped compiler errors emitting spurious file:1:1: prefix Apr 3, 2026
Copilot AI requested a review from pelikhan April 3, 2026 14:02
@pelikhan pelikhan marked this pull request as ready for review April 3, 2026 14:06
Copilot AI review requested due to automatic review settings April 3, 2026 14:06
Copy link
Copy Markdown
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

Fixes double-wrapped compiler errors that were incorrectly gaining a spurious file:1:1: error: prefix when the underlying error string already contained a file:line:col: location.

Changes:

  • Return *parser.FormattedParserError (instead of plain errors.New/fmt.Errorf) from schema validation and frontmatter YAML formatting paths so isFormattedCompilerError() can detect and pass them through.
  • Add parser.NewFormattedParserError(formatted string) for use by external packages (e.g., pkg/workflow).
  • Add a unit test covering the new NewFormattedParserError detection path.

Reviewed changes

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

File Description
pkg/workflow/frontmatter_error.go Switch already-formatted YAML error returns to parser.NewFormattedParserError(...) to avoid re-wrapping.
pkg/workflow/compiler_error_formatter_test.go Add test case ensuring parser.NewFormattedParserError is recognized by isFormattedCompilerError.
pkg/parser/schema_compiler.go Return *FormattedParserError for schema validation errors that are already console-formatted.
pkg/parser/import_error.go Add exported constructor NewFormattedParserError for cross-package creation of formatted sentinel errors.
Comments suppressed due to low confidence (1)

pkg/parser/schema_compiler.go:385

  • Same as above: this formatted return currently loses the underlying validation error because cause is left nil. Consider setting cause: err so the formatted wrapper still preserves the original error for errors.Is/As traversal.
		// Format and return the error
		formattedErr := console.FormatError(compilerErr)
		return &FormattedParserError{formatted: formattedErr}

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

// Format and return the error
formattedErr := console.FormatError(compilerErr)
return errors.New(formattedErr)
return &FormattedParserError{formatted: formattedErr}
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

FormattedParserError supports error-chain preservation via Unwrap(), but this new return drops the underlying schema validation error by leaving cause unset. Consider setting cause: err here so callers can still use errors.Is/As on the original validation error when needed (while keeping the formatted display string).

This issue also appears on line 383 of the same file.

Suggested change
return &FormattedParserError{formatted: formattedErr}
return &FormattedParserError{formatted: formattedErr, cause: err}

Copilot uses AI. Check for mistakes.
Comment on lines +89 to +91
// that isFormattedCompilerError can detect without double-wrapping.
func NewFormattedParserError(formatted string) *FormattedParserError {
return &FormattedParserError{formatted: formatted}
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

NewFormattedParserError always returns a FormattedParserError with a nil cause, which means external callers (like pkg/workflow) can't preserve the underlying error chain even though FormattedParserError exposes Unwrap(). Consider adding an additional constructor (or extending this one) that accepts an optional cause error and sets it, so callers can keep errors.Is/As behavior without reintroducing double-formatting.

Suggested change
// that isFormattedCompilerError can detect without double-wrapping.
func NewFormattedParserError(formatted string) *FormattedParserError {
return &FormattedParserError{formatted: formatted}
// that isFormattedCompilerError can detect without double-wrapping. An optional cause
// may be provided so callers can preserve errors.Is/errors.As traversal without
// re-formatting the wrapped error.
func NewFormattedParserError(formatted string, cause ...error) *FormattedParserError {
var wrappedCause error
if len(cause) > 0 {
wrappedCause = cause[0]
}
return &FormattedParserError{formatted: formatted, cause: wrappedCause}

Copilot uses AI. Check for mistakes.
@pelikhan pelikhan merged commit feb866d into main Apr 3, 2026
179 checks passed
@pelikhan pelikhan deleted the copilot/fix-compiler-error-messages-formatting branch April 3, 2026 14:16
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.

[syntax-error-quality] Compiler error messages double-format with wrong line number (file:1:1 prefix)

3 participants