chore: remove toml and json parser#8
Conversation
📝 WalkthroughWalkthroughThis pull request removes TOML support from the codebase, consolidating file configuration parsing to YAML only. Changes include removing TOML dependency, deleting TOML fixture files, refactoring file decoding logic to reject non-YAML extensions, and updating tests and fixtures accordingly. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Warning Review ran into problems🔥 ProblemsGit: Failed to clone repository. Please run the Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@file/file_node.go`:
- Around line 23-33: The extension gate in file_node.go uses supportedExtensions
and slices.Contains to reject unsupported files, but cli/loader_file.go still
tries TOML first which causes premature failure; either remove "toml" from the
loader's candidate search order in cli/loader_file.go so it no longer probes
TOML before yaml/yml, or change the loader's candidate loop to check the
extension against supportedExtensions (or call the same validation used in the
FileNode code) and skip unsupported candidates (continue) instead of returning
an error—update the loader logic that iterates candidates to consult
supportedExtensions/slices.Contains before attempting to load.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 3b4c18a1-7ecd-4f0b-a8cc-10ac3acbbc42
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (13)
cli/commands_test.gocli/fixtures/config.tomlcli/fixtures/config.ymlfile/file.gofile/file_node.gofile/file_node_test.gofile/file_test.gofile/fixtures/empty.ymlfile/fixtures/no_conf.tomlfile/fixtures/no_conf.ymlfile/fixtures/sample.jsonfile/fixtures/sample.tomlgo.mod
💤 Files with no reviewable changes (6)
- cli/fixtures/config.toml
- file/fixtures/no_conf.toml
- go.mod
- file/fixtures/sample.json
- file/fixtures/sample.toml
- file/file_test.go
| extension := filepath.Ext(filePath) | ||
|
|
||
| switch strings.ToLower(filepath.Ext(filePath)) { | ||
| case ".toml": | ||
| err = toml.Unmarshal(content, &data) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
|
|
||
| case ".yml", ".yaml", ".json": | ||
| err = yaml.Unmarshal(content, data) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| if !slices.Contains(supportedExtensions, extension) { | ||
|
|
||
| default: | ||
| return nil, fmt.Errorf("unsupported file extension: %s", filePath) | ||
| } | ||
|
|
||
| err = yaml.Unmarshal(content, data) | ||
| if err != nil { | ||
| return nil, err | ||
| } |
There was a problem hiding this comment.
Keep TOML discovery in sync with this extension gate.
cli/loader_file.go still searches toml ahead of yaml/yml, so a config directory with both files will now fail on the TOML hit instead of continuing to the YAML file. Please remove TOML from the search list in the same change set, or have the loader skip unsupported candidates and continue.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@file/file_node.go` around lines 23 - 33, The extension gate in file_node.go
uses supportedExtensions and slices.Contains to reject unsupported files, but
cli/loader_file.go still tries TOML first which causes premature failure; either
remove "toml" from the loader's candidate search order in cli/loader_file.go so
it no longer probes TOML before yaml/yml, or change the loader's candidate loop
to check the extension against supportedExtensions (or call the same validation
used in the FileNode code) and skip unsupported candidates (continue) instead of
returning an error—update the loader logic that iterates candidates to consult
supportedExtensions/slices.Contains before attempting to load.
Summary by CodeRabbit
.ymland.yamlextensions) are now supported. Previously supported TOML and JSON configuration formats are no longer accepted. Using these formats will result in an "unsupported file extension" error.