Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces a 'SkipSourceInitialization' configuration option, allowing the server to proceed with uninitialized sources using a placeholder 'UninitializedSource' struct. This is particularly useful for CLI tools or environments where full source connectivity isn't immediately required. Feedback suggests improving log searchability by using structured logging attributes and adding panic recovery to handle potential type assertion failures on uninitialized sources. Additionally, the PR title and description must be updated to comply with the repository's style guide regarding Conventional Commits and the required template.
| t, err := tc.Initialize(sourcesMap) | ||
| if err != nil { | ||
| if cfg.SkipSourceInitialization { | ||
| l.WarnContext(ctx, fmt.Sprintf("unable to initialize tool %q (source skip enabled): %v", name, err)) |
There was a problem hiding this comment.
Leveraging structured logging by passing the tool name and error as separate attributes is preferred over fmt.Sprintf. This improves log searchability and consistency with other parts of the codebase (e.g., line 465).
Additionally, consider wrapping the tc.Initialize call in a recover() block when SkipSourceInitialization is enabled. This would prevent the server (or CLI tool) from crashing if a tool performs a concrete type assertion on an UninitializedSource and panics.
| l.WarnContext(ctx, fmt.Sprintf("unable to initialize tool %q (source skip enabled): %v", name, err)) | |
| l.WarnContext(ctx, "unable to initialize tool (source skip enabled)", "tool", name, "error", err) |
| // SkipSourceInitialization indicates if the server should skip initializing sources. | ||
| SkipSourceInitialization bool |
There was a problem hiding this comment.
The pull request title and description do not adhere to the repository's style guide.
- Title: Should follow the Conventional Commits format (e.g.,
feat(server): add skip source initialization option). Currently:skip source init exp. - Description: The provided description is empty and contains only the template placeholders. Please provide a concise summary of the changes and their impact.
Description
PR Checklist
CONTRIBUTING.md
bug/issue
before writing your code! That way we can discuss the change, evaluate
designs, and agree on the general idea
!if this involve a breaking change🛠️ Fixes #<issue_number_goes_here>