refactor(config): clean up BurntSushi/toml usage in LoadFromFile#4483
refactor(config): clean up BurntSushi/toml usage in LoadFromFile#4483
Conversation
Agent-Logs-Url: https://github.com/github/gh-aw-mcpg/sessions/bda1e07b-b21e-4849-9933-e372accda40d Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Refactors LoadFromFile TOML parsing to simplify BurntSushi/toml error handling and improve the surrounding documentation.
Changes:
- Removes a dead
toml.ParseErrortype-assertion branch (both branches wrapped the same way). - Corrects the parsing comment to reference
decoder.Decode(nottoml.Decode). - Expands
LoadFromFilegodoc, including guidance on usingerrors.Asto extracttoml.ParseError.
Show a summary per file
| File | Description |
|---|---|
| internal/config/config_core.go | Simplifies parse-error wrapping and updates/expands LoadFromFile documentation. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 2
| // var perr toml.ParseError | ||
| // if errors.As(err, &perr) { | ||
| // fmt.Println(perr.Position()) | ||
| // } |
There was a problem hiding this comment.
Within the new godoc code blocks, some lines are indented using spaces (e.g., the fmt.Println(...) line in the errors.As snippet). Other godoc examples in the repo use tab indentation (e.g., internal/auth/header.go:24-34), which also aligns with gofmt-style formatting and consistent rendering in godoc. Consider switching these code-block indents to tabs.
| // LoadFromFile parses a TOML configuration file at path and returns the | ||
| // validated Config, or an error if the file cannot be opened, parsed, or | ||
| // contains unknown fields. |
There was a problem hiding this comment.
The docstring summary says LoadFromFile errors only when the file can’t be opened/parsed or contains unknown fields, but the function also returns validation errors (e.g., no servers defined, containerization/auth/tracing/trusted_bots validations, etc.). Update the summary to include validation failures so callers aren’t misled about possible error cases.
|
@copilot address this review feedback #4483 (review) |
Agent-Logs-Url: https://github.com/github/gh-aw-mcpg/sessions/7fa2f3ef-54c2-451e-8fbc-86d44cfa64a1 Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Done in 93dd347:
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:
If you need me to access, download, or install something from one of these locations, you can either:
|
Three minor cleanup items identified in a Go Fan module review of
BurntSushi/tomlusage ininternal/config/config_core.go.Changes
ParseErrortype assertion produced identical output (fmt.Errorf("failed to parse TOML: %w", ...)); collapsed to a single returndecoder.Decode(theDecodermethod) is what's called, not the top-leveltoml.DecodefunctionLoadFromFilegodoc — add canonical function-name prefix; document theerrors.Aspattern for callers that need structured parse-error details (line/column/source snippet)The
%wverb already preserves the concretetoml.ParseErrortype through the wrapping, so downstream callers can still useerrors.Asto extract line/column info — now documented in the godoc.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:
example.com/tmp/go-build3345233236/b509/launcher.test /tmp/go-build3345233236/b509/launcher.test -test.testlogfile=/tmp/go-build3345233236/b509/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true ache/go/1.25.9/x-p go x_amd64/vet(dns block)/tmp/go-build1779078529/b513/launcher.test /tmp/go-build1779078529/b513/launcher.test -test.testlogfile=/tmp/go-build1779078529/b513/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build1779078529/b497/vet.cfg pkg/mod/go.opentelemetry.io/otel@v1.43.0/semconvgo1.25.9 -trimpath .cfg -p cptest -lang=go1.17 ache/go/1.25.9/x64/pkg/tool/linux_amd64/vet -W -I /tmp/go-build3345233236/b346/ x_amd64/vet . --gdwarf2 --64 x_amd64/vet(dns block)invalid-host-that-does-not-exist-12345.com/tmp/go-build3345233236/b491/config.test /tmp/go-build3345233236/b491/config.test -test.testlogfile=/tmp/go-build3345233236/b491/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true linux.go 64/src/vendor/gogoogle.golang.org/grpc/credentials x_amd64/compile(dns block)/tmp/go-build1779078529/b495/config.test /tmp/go-build1779078529/b495/config.test -test.testlogfile=/tmp/go-build1779078529/b495/testlog.txt -test.paniconexit0 -test.timeout=10m0s 5233�� g_.a ache/go/1.25.9/x64/src/net/http/internal/httpcommon/httpcommon.ggoogle.golang.org/grpc/internal//tmp/go-build3510073492/b354/vet.cfg docker-compose -errorsas ernal/tracing -nilfunc docker-compose -o mnvzNK45F -trimpath ache/go/1.25.9/x64/pkg/tool/linux_amd64/vet -p net/http -lang=go1.25 ortcfg(dns block)nonexistent.local/tmp/go-build3345233236/b509/launcher.test /tmp/go-build3345233236/b509/launcher.test -test.testlogfile=/tmp/go-build3345233236/b509/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true ache/go/1.25.9/x-p go x_amd64/vet(dns block)/tmp/go-build1779078529/b513/launcher.test /tmp/go-build1779078529/b513/launcher.test -test.testlogfile=/tmp/go-build1779078529/b513/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build1779078529/b497/vet.cfg pkg/mod/go.opentelemetry.io/otel@v1.43.0/semconvgo1.25.9 -trimpath .cfg -p cptest -lang=go1.17 ache/go/1.25.9/x64/pkg/tool/linux_amd64/vet -W -I /tmp/go-build3345233236/b346/ x_amd64/vet . --gdwarf2 --64 x_amd64/vet(dns block)slow.example.com/tmp/go-build3345233236/b509/launcher.test /tmp/go-build3345233236/b509/launcher.test -test.testlogfile=/tmp/go-build3345233236/b509/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true ache/go/1.25.9/x-p go x_amd64/vet(dns block)/tmp/go-build1779078529/b513/launcher.test /tmp/go-build1779078529/b513/launcher.test -test.testlogfile=/tmp/go-build1779078529/b513/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build1779078529/b497/vet.cfg pkg/mod/go.opentelemetry.io/otel@v1.43.0/semconvgo1.25.9 -trimpath .cfg -p cptest -lang=go1.17 ache/go/1.25.9/x64/pkg/tool/linux_amd64/vet -W -I /tmp/go-build3345233236/b346/ x_amd64/vet . --gdwarf2 --64 x_amd64/vet(dns block)this-host-does-not-exist-12345.com/tmp/go-build3345233236/b518/mcp.test /tmp/go-build3345233236/b518/mcp.test -test.testlogfile=/tmp/go-build3345233236/b518/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true se httptrace/trace.go x_amd64/vet -I /tmp/go-build334--version -I x_amd64/vet -I /opt/hostedtoolcache/go/1.25.9/x-errorsas .cfg x_amd64/vet --gdwarf-5 --64 -o x_amd64/vet(dns block)/tmp/go-build1779078529/b522/mcp.test /tmp/go-build1779078529/b522/mcp.test -test.testlogfile=/tmp/go-build1779078529/b522/testlog.txt -test.paniconexit0 -test.timeout=10m0s -W -I /tmp/go-build3345233236/b346/ x_amd64/vet . --gdwarf2 --64 x_amd64/vet -I /opt/hostedtoolc-s -I x_amd64/vet --gdwarf-5 --64 -o x_amd64/vet(dns block)If you need me to access, download, or install something from one of these locations, you can either: