You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
github.com/BurntSushi/toml (v1.6.0) is the de-facto standard TOML parser and encoder for Go. It provides full TOML 1.1 specification compliance, column-level parse error reporting, streaming decode, and metadata-based unknown field discovery. It is the only external TOML dependency in this project, used exclusively in the config loading subsystem.
Current Usage in gh-aw
The module is used in 2 files, both within internal/config/:
File
Role
internal/config/config_core.go
Production config loading
internal/config/config_core_test.go
Tests for key path logic
Import Count: 1 import site (production), 1 import site (test)
decoder.Decode(&cfg) → (MetaData, error) — Decode TOML into struct
MetaData.Undecoded() → []toml.Key — Detect keys present in TOML but not in struct
toml.Key ([]string) — Key path representation
toml.ParseError — Structured error with line + column info
Key.String() — Display representation of key paths
The config loader uses a sophisticated approach: streaming decode + manual unknown-field rejection via MetaData.Undecoded(), with a custom isDynamicTOMLPath() filter to exempt guard_policies and guards.*.config sections (which use map[string]interface{} and accept arbitrary keys by design).
Research Findings
Recent Updates (v1.6.0)
Full TOML 1.1 specification compliance
Multi-line inline arrays and inline tables
Improved duplicate key detection (properly raised as errors)
Column-level error positions for precise diagnostics
Best Practices
Use toml.NewDecoder for streaming (not toml.DecodeFile when you need MetaData)
Use MetaData.Undecoded() for unknown-field validation
Decoder.SetStrict(true) exists but rejects ALL undecoded keys — incompatible with map[string]interface{} sections
ParseError is a value type — can be type-asserted or matched with errors.As
Improvement Opportunities
🏃 Quick Wins
1. Remove redundant ParseError type assertion (Low risk, cosmetic)
In internal/config/config_core.go (LoadFromFile), the two error branches produce identical output:
// Current (lines 339–342) — both branches wrap the error identicallyifperr, ok:=err.(toml.ParseError); ok {
returnnil, fmt.Errorf("failed to parse TOML: %w", perr)
}
returnnil, fmt.Errorf("failed to parse TOML: %w", err)
When err is a toml.ParseError, perr and err wrap the same value. The %w verb in both branches produces the same wrapped error. This can be simplified to:
// Simplified — semantically equivalent, removes dead branchreturnnil, fmt.Errorf("failed to parse TOML: %w", err)
The ParseError rich formatting (line snippets, column pointers) is preserved in both forms since fmt.Errorf("%w", err) delegates to ParseError.Error() for display.
✨ Feature Opportunities
2. Consider toml.Unmarshal in tests (Low risk, test quality)
Several tests in config_core_test.go write TOML content to temp files just to call LoadFromFile. For test cases that validate the isDynamicTOMLPath logic directly, toml.Key literals are already used efficiently. However, for future tests of parsing-only behavior, toml.Unmarshal([]byte(content), &cfg) could reduce test boilerplate where file I/O isn't the subject.
📐 Best Practice Alignment
3. Clarify comment on decoder.Decode vs toml.Decode (Cosmetic)
The comment at line 336 says "toml.Decode returns ParseError as a value type" — technically correct about the type, but decoder.Decode (the Decoder method) is what's being called, not the top-level toml.Decode function. Clarifying this avoids potential confusion for future maintainers.
4. Document errors.As pattern for ParseError callers
The current wrapping (fmt.Errorf("failed to parse TOML: %w", err)) means downstream callers can use errors.As(&perr, ...) to extract the structured parse error. This is not documented anywhere. Adding a note in the LoadFromFile doc comment would help callers that need line/column info.
🔧 General Improvements
The overall usage is already excellent:
Streaming decoder is correctly used (no full-file buffering)
MetaData.Undecoded() is the right API for unknown-field detection
isDynamicTOMLPath correctly handles the map[string]interface{} exception case
TOML 1.1 features are documented in the package-level comment
Error handling preserves structured errors via %w
The main finding is the redundant ParseError type check — a minor cleanup opportunity.
Recommendations
[Easy] Remove the redundant ParseError type assertion in LoadFromFile — simplifies code with no behavior change
[Low priority] Improve comment accuracy: "decoder.Decode" not "toml.Decode"
[Documentation] Add errors.As note to LoadFromFile doc comment for callers needing structured parse errors
🐹 Go Fan Report: BurntSushi/toml
Module Overview
github.com/BurntSushi/toml(v1.6.0) is the de-facto standard TOML parser and encoder for Go. It provides full TOML 1.1 specification compliance, column-level parse error reporting, streaming decode, and metadata-based unknown field discovery. It is the only external TOML dependency in this project, used exclusively in the config loading subsystem.Current Usage in gh-aw
The module is used in 2 files, both within
internal/config/:internal/config/config_core.gointernal/config/config_core_test.goImport Count: 1 import site (production), 1 import site (test)
Key APIs Used:
toml.NewDecoder(io.Reader)— Streaming file decode (memory efficient)decoder.Decode(&cfg) → (MetaData, error)— Decode TOML into structMetaData.Undecoded() → []toml.Key— Detect keys present in TOML but not in structtoml.Key([]string) — Key path representationtoml.ParseError— Structured error with line + column infoKey.String()— Display representation of key pathsThe config loader uses a sophisticated approach: streaming decode + manual unknown-field rejection via
MetaData.Undecoded(), with a customisDynamicTOMLPath()filter to exemptguard_policiesandguards.*.configsections (which usemap[string]interface{}and accept arbitrary keys by design).Research Findings
Recent Updates (v1.6.0)
Best Practices
toml.NewDecoderfor streaming (nottoml.DecodeFilewhen you needMetaData)MetaData.Undecoded()for unknown-field validationDecoder.SetStrict(true)exists but rejects ALL undecoded keys — incompatible withmap[string]interface{}sectionsParseErroris a value type — can be type-asserted or matched witherrors.AsImprovement Opportunities
🏃 Quick Wins
1. Remove redundant
ParseErrortype assertion (Low risk, cosmetic)In
internal/config/config_core.go(LoadFromFile), the two error branches produce identical output:When
erris atoml.ParseError,perranderrwrap the same value. The%wverb in both branches produces the same wrapped error. This can be simplified to:The
ParseErrorrich formatting (line snippets, column pointers) is preserved in both forms sincefmt.Errorf("%w", err)delegates toParseError.Error()for display.✨ Feature Opportunities
2. Consider
toml.Unmarshalin tests (Low risk, test quality)Several tests in
config_core_test.gowrite TOML content to temp files just to callLoadFromFile. For test cases that validate theisDynamicTOMLPathlogic directly,toml.Keyliterals are already used efficiently. However, for future tests of parsing-only behavior,toml.Unmarshal([]byte(content), &cfg)could reduce test boilerplate where file I/O isn't the subject.📐 Best Practice Alignment
3. Clarify comment on
decoder.Decodevstoml.Decode(Cosmetic)The comment at line 336 says "toml.Decode returns ParseError as a value type" — technically correct about the type, but
decoder.Decode(the Decoder method) is what's being called, not the top-leveltoml.Decodefunction. Clarifying this avoids potential confusion for future maintainers.4. Document
errors.Aspattern forParseErrorcallersThe current wrapping (
fmt.Errorf("failed to parse TOML: %w", err)) means downstream callers can useerrors.As(&perr, ...)to extract the structured parse error. This is not documented anywhere. Adding a note in theLoadFromFiledoc comment would help callers that need line/column info.🔧 General Improvements
The overall usage is already excellent:
MetaData.Undecoded()is the right API for unknown-field detectionisDynamicTOMLPathcorrectly handles themap[string]interface{}exception case%wThe main finding is the redundant ParseError type check — a minor cleanup opportunity.
Recommendations
ParseErrortype assertion inLoadFromFile— simplifies code with no behavior changeerrors.Asnote toLoadFromFiledoc comment for callers needing structured parse errorsNext Steps
Generated by Go Fan 🐹
Module summary saved to: session-state/files/burntSushi-toml.md
Run ID: §24766373325
Note
🔒 Integrity filter blocked 22 items
The following items were blocked because they don't meet the GitHub integrity level.
get_latest_release: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".get_latest_release: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".get_latest_release: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".get_latest_release: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".get_latest_release: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".list_commits: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".list_commits: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".list_commits: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".list_commits: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".list_commits: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".get_file_contents: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".list_branches: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".list_issues: has lower integrity than agent requires. The agent cannot read data with integrity below "unapproved".To allow these resources, lower
min-integrityin your GitHub frontmatter: