Fix crash on malformed local mixin YAML#334
Merged
Conversation
Contributor
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
Reviewer's GuideImplements safer error handling when loading mixins so malformed local mixin YAML no longer crashes the loader, standardizes mixin source reporting via a new helper, adds a regression test, and documents the fix in the changelog. Sequence diagram for mixin load error handling using SourcesequenceDiagram
actor User
participant App
participant Config
participant Mixin
User->>App: run command with mixins
App->>Config: readMixins(mixins)
loop for each mixin
Config->>Mixin: readMixin(mixin)
Mixin-->>Config: error on malformed YAML
alt error returned
Config->>Mixin: Source()
Mixin-->>Config: source string (FileName or URL)
Config-->>App: error failed to read mixin config 'source'
end
end
App-->>User: display parse error without crash
Class diagram for updated Mixin and Config mixin loadingclassDiagram
class Mixin {
string FileName
RemoteMixin* Remote
UnmarshalYAML(unmarshal func_any_error) error
IsRemote() bool
Source() string
}
class RemoteMixin {
string URL
}
class Config {
readMixins(mixins []*Mixin) error
readMixin(mixin *Mixin) error
}
Mixin --> RemoteMixin : has
Config --> Mixin : reads
File-Level Changes
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Remotewhen reporting mixin load errors for local mixinsMixin.Source()so error messages use the correct local file name or remote URLTesting
lets fmtgo test ./internal/config/...go test ./...Summary by Sourcery
Handle malformed local mixin YAML without crashing and ensure error reporting uses the correct mixin source identifier.
Bug Fixes:
Enhancements:
Documentation:
Tests: