pkg/config: accept string shorthand for the projects list#53
Merged
textfuel merged 2 commits intotextfuel:mainfrom Apr 18, 2026
Merged
pkg/config: accept string shorthand for the projects list#53textfuel merged 2 commits intotextfuel:mainfrom
textfuel merged 2 commits intotextfuel:mainfrom
Conversation
Owner
|
could you resolve the merge conflicts with main so I can merge |
A config.yml entry of the form projects: - ORCH panicked lazyjira on startup with panic: runtime error: invalid memory address or nil pointer dereference main.resolveClient(0x0) cmd/lazyjira/main.go:155 +0xc0 because `projects:` is typed as []ProjectConfig. yaml.v3 refuses to map a scalar into a struct and returns "cannot unmarshal !!str into config.ProjectConfig", which Load() propagated as (nil, err) and resolveClient happily dereferenced anyway. Give ProjectConfig a custom UnmarshalYAML that treats scalar nodes as the Key value and falls through to the normal struct decode for full mapping nodes. A type alias is used for the struct branch so the fallthrough does not recurse into this method. Both forms can now be mixed in the same list, which matches what the docs / README imply when they show single-string entries. Fixes textfuel#41 Signed-off-by: SAY-5 <[email protected]>
eaa9c8c to
48b8c56
Compare
Contributor
Author
|
Thanks for the review! Rebased on top of latest main, conflicts resolved. Ready to merge when you are. |
textfuel
approved these changes
Apr 18, 2026
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.
Problem
The config schema declares
so the most natural form that users reach for:
errors out of yaml.v3 with
cannot unmarshal !!str into config.ProjectConfig.On v2.8.1 this bubbled up through
cfg, _ := config.Load()as a nil *Configand crashed with a SIGSEGV the moment
resolveClienttouchedcfg.Jira.Host(#41). main.go already returns the error cleanly, so the crash itself is
gone, but the shorthand form still isn't accepted.
Fix
Add
UnmarshalYAMLtoProjectConfigso it accepts either form:Scalar nodes are decoded straight into
Key. Mapping nodes go through alocal type alias so the method doesn't recurse into itself. Added a test
that covers both forms in the same list.
Refs #41