fix(config): make endpoints optional and use relative schema path#175
fix(config): make endpoints optional and use relative schema path#175
Conversation
- Add omitempty tag to Endpoints field for proper optional serialization - Change YAML schema reference to relative path ./config-schema.json 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Summary of ChangesHello @AnnatarHe, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the configuration system by making the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Codecov Report❌ Patch coverage is
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request makes the Endpoints field optional in the configuration and updates the YAML schema path to be relative. My review focuses on improving path handling for cross-platform compatibility, reducing code duplication, and ensuring consistency between your configuration struct tags and your documentation. I've suggested using filepath.Join for constructing paths, deriving the schema filename dynamically to avoid hardcoding it twice, and correcting an inconsistent TOML tag to match your documentation.
|
|
||
| // Generate JSON schema for IDE autocompletion | ||
| schemaFile := configDir + "/config.schema.json" | ||
| schemaFile := configDir + "/config-schema.json" |
There was a problem hiding this comment.
To ensure platform-independent path construction, you should use filepath.Join instead of string concatenation with /. This will prevent potential issues on operating systems like Windows that use a different path separator. This follows the repository's general rule for path handling.
You'll need to add "path/filepath" to your imports.
| schemaFile := configDir + "/config-schema.json" | |
| schemaFile := filepath.Join(configDir, "config-schema.json") |
References
- Use
filepath.Jointo combine path segments for platform independence, rather than hardcoding path separators.
| } | ||
| // Prepend $schema for IDE autocompletion support | ||
| schemaHeader := "# yaml-language-server: $schema=" + schemaFile + "\n" | ||
| schemaHeader := "# yaml-language-server: $schema=./config-schema.json\n" |
There was a problem hiding this comment.
The schema filename config-schema.json is hardcoded here, but it's already used to construct schemaFile on line 48. To avoid this duplication and improve maintainability, you can dynamically get the filename from the schemaFile path using filepath.Base().
This will require importing the path/filepath package.
| schemaHeader := "# yaml-language-server: $schema=./config-schema.json\n" | |
| schemaHeader := fmt.Sprintf("# yaml-language-server: $schema=./%s\n", filepath.Base(schemaFile)) |
|
|
||
| // for debug purpose | ||
| Endpoints []Endpoint `toml:"ENDPOINTS" yaml:"endpoints" json:"endpoints"` | ||
| Endpoints []Endpoint `toml:"ENDPOINTS,omitempty" yaml:"endpoints,omitempty" json:"endpoints,omitempty"` |
There was a problem hiding this comment.
The TOML tag ENDPOINTS is in uppercase, which is inconsistent with the YAML and JSON tags (endpoints). More importantly, it contradicts your own documentation in docs/CONFIG.md (line 308) which uses [[endpoints]] (lowercase). To ensure consistency and align with your documentation, you should use a lowercase tag for TOML as well.
| Endpoints []Endpoint `toml:"ENDPOINTS,omitempty" yaml:"endpoints,omitempty" json:"endpoints,omitempty"` | |
| Endpoints []Endpoint `toml:"endpoints,omitempty" yaml:"endpoints,omitempty" json:"endpoints,omitempty"` |
Summary
omitemptytag toEndpointsfield in config struct for proper optional serialization./config-schema.jsonTest plan
🤖 Generated with Claude Code