Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@kindermax
Copy link
Collaborator

@kindermax kindermax commented Oct 21, 2025

Summary by Sourcery

Enforce allowed content types for remote mixins and refine error reporting, while updating Neovim LSP configuration documentation

New Features:

  • Validate HTTP Content-Type when downloading remote mixins to only allow YAML or plain text
  • Error out on unsupported mixin content types

Enhancements:

  • Wrap remote mixin read errors with a descriptive message including the mixin URL

Documentation:

  • Update Neovim IDE support documentation to define lets_ls using vim.lsp.config and vim.lsp.enable
  • Specify Neovim >= 0.11.2 requirement and use root_markers instead of util.root_pattern

@sourcery-ai
Copy link

sourcery-ai bot commented Oct 21, 2025

Reviewer's Guide

Implement content-type checking for remote mixin downloads with contextual error wrapping and refresh IDE support documentation to align Neovim LSP setup for lets_ls on Neovim >= 0.11.2.

Sequence diagram for remote mixin download with content-type validation

sequenceDiagram
participant Config
participant RemoteMixin
participant HTTPServer
Config->>RemoteMixin: download()
RemoteMixin->>HTTPServer: GET mixin URL
HTTPServer-->>RemoteMixin: Response (with Content-Type)
RemoteMixin->>RemoteMixin: Check Content-Type
alt Content-Type allowed
    RemoteMixin->>RemoteMixin: Read response body
    RemoteMixin-->>Config: Return mixin data
else Content-Type not allowed
    RemoteMixin-->>Config: Return error (unsupported content type)
end
Loading

Class diagram for RemoteMixin content-type validation

classDiagram
class RemoteMixin {
  +download() error
}
class set.Set {
  +Contains(string) bool
}
RemoteMixin --> set.Set : uses allowedContentTypes
Loading

Class diagram for improved error wrapping in Config.readMixins

classDiagram
class Config {
  +readMixins(mixins []*Mixin) error
}
class Mixin {
  Remote RemoteMixin
}
Config --> Mixin : reads mixins
Mixin --> RemoteMixin : has Remote
Loading

File-Level Changes

Change Details Files
Validate remote mixin Content-Type header before reading response
  • Import set package to manage allowed MIME types
  • Define a set of permitted content types for mixin downloads
  • Retrieve and validate the Content-Type header from HTTP responses
  • Return an error when encountering unsupported content types
config/config/mixin.go
Enhance error context when reading remote mixins
  • Wrap errors from readMixin with contextual remote URL information
config/config/config.go
Revise IDE support docs for Neovim LSP configuration of lets_ls
  • Update instructions to require Neovim >= 0.11.2
  • Switch from lspconfig.configs to vim.lsp.config for defining lets_ls
  • Use vim.lsp.enable to activate lets_ls
  • Simplify example configuration and highlight conventional naming
docs/docs/ide_support.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes - here's some feedback:

  • In mixin.go, Content-Type headers often include parameters (e.g. charset); consider parsing and normalizing the media type (using mime.ParseMediaType or stripping parameters) before checking against allowedContentTypes.
  • Verify that the updated Neovim LSP config steps (vim.lsp.config.lets_ls and vim.lsp.enable("lets_ls")) align with the actual nvim-lspconfig API in 0.11.2 to avoid mismatches.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- In mixin.go, Content-Type headers often include parameters (e.g. charset); consider parsing and normalizing the media type (using mime.ParseMediaType or stripping parameters) before checking against allowedContentTypes.
- Verify that the updated Neovim LSP config steps (vim.lsp.config.lets_ls and vim.lsp.enable("lets_ls")) align with the actual nvim-lspconfig API in 0.11.2 to avoid mismatches.

## Individual Comments

### Comment 1
<location> `config/config/mixin.go:19-17` </location>
<code_context>
 	"github.com/lets-cli/lets/util"
 )

+var allowedContentTypes = set.NewSet(
+	"text/plain",
+	"text/yaml",
+	"text/x-yaml",
+	"application/yaml",
+	"application/x-yaml",
+)
+
 type Mixins []*Mixin
</code_context>

<issue_to_address>
**suggestion:** Consider normalizing Content-Type values for more robust matching.

Servers may include parameters like charset in the Content-Type header. Matching only the MIME type portion will help avoid false negatives.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@kindermax kindermax merged commit 16bd131 into master Oct 21, 2025
5 checks passed
@kindermax kindermax deleted the check-remote-mixin-content-type branch October 21, 2025 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants