Fix double-wrapped compiler errors emitting spurious file:1:1: prefix#24316
Fix double-wrapped compiler errors emitting spurious file:1:1: prefix#24316
file:1:1: prefix#24316Conversation
- 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>
file:1:1: prefix
There was a problem hiding this comment.
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 plainerrors.New/fmt.Errorf) from schema validation and frontmatter YAML formatting paths soisFormattedCompilerError()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
NewFormattedParserErrordetection 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
causeis left nil. Consider settingcause: errso 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} |
There was a problem hiding this comment.
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.
| return &FormattedParserError{formatted: formattedErr} | |
| return &FormattedParserError{formatted: formattedErr, cause: err} |
| // that isFormattedCompilerError can detect without double-wrapping. | ||
| func NewFormattedParserError(formatted string) *FormattedParserError { | ||
| return &FormattedParserError{formatted: formatted} |
There was a problem hiding this comment.
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.
| // 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} |
All compiler errors were being double-formatted: the inner message already contained the correct
file:line:col:location, butcompiler.gowrapped it again with afile:1:1: error:prefix becauseisFormattedCompilerError()only recognises*wrappedCompilerErrorand*parser.FormattedParserError— not the plainerrors.New/fmt.Errorfvalues returned by the two offending paths.Root cause
pkg/parser/schema_compiler.go(validateWithSchemaAndLocation) — returnederrors.New(formattedErr)after building a fully-formattedconsole.CompilerErrorstringpkg/workflow/frontmatter_error.go(createFrontmatterError) — returnedfmt.Errorf("%s\n%s", vscodeFormat, context)for already-formatted YAML errorsBoth evaded the
isFormattedCompilerErrorcheck, triggering a second wrap atfile:1:1.Changes
pkg/parser/schema_compiler.go— replace botherrors.New(formattedErr)returns with&FormattedParserError{formatted: formattedErr}(same package, direct field access)pkg/parser/import_error.go— addNewFormattedParserError(formatted string)constructor for use by external packagespkg/workflow/frontmatter_error.go— replacefmt.Errorf(...)on the pre-formatted YAML paths withparser.NewFormattedParserError(...)pkg/workflow/compiler_error_formatter_test.go— add coverage for theNewFormattedParserErrorpathWarning
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/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/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/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/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/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)/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)/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/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)/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)/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/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)/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)/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/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/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/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/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/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/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/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/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/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/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/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/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/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)/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)/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/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/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/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/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)/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/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/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/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/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)/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/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/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: