Skip to content

fix: return error when config file cannot be parsed - #574

Open
Sarthak-Shreshtha01 wants to merge 2 commits into
microcks:masterfrom
Sarthak-Shreshtha01:fix/issue-572
Open

Sarthak-Shreshtha01 wants to merge 2 commits into
microcks:masterfrom
Sarthak-Shreshtha01:fix/issue-572

Conversation

@Sarthak-Shreshtha01

Copy link
Copy Markdown

ReadLocalConfig and ReadLocalWatchConfig now return an error when the config file has invalid YAML, instead of an empty config. Before, login treated the broken file as a fresh install and overwrote all other contexts. The related tests pass, including the new TestReadMalformedConfig.

Fixes #572

Signed-off-by: Sarthak <sarthakshreshtha345@gmail.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@gyanranjanpanda

gyanranjanpanda commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Hi @Sarthak-Shreshtha01, thank you for submitting this PR!

It looks like the review couldn't complete because your GitHub Copilot review quota was reached. Additionally, please make sure to check our contribution guidelines and this issue #559 regarding monthly PR limits before creating a new PR. Thanks again for contributing!

Comment thread pkg/config/localconfig.go
Comment on lines +107 to +109
if err != nil {
return nil, fmt.Errorf("reading config %s: %w", path, err)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

let's make sure we're using our centralised error handling mechanism.

Comment thread pkg/config/localconfig.go
Comment on lines +423 to +425
if err != nil {
return nil, fmt.Errorf("reading config %s: %w", path, err)
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same here

@Harsh4902 Harsh4902 added kind/bug Something isn't working component/cli and removed kind/bug Something isn't working labels Oct 9, 2026
@Harsh4902 Harsh4902 added this to the Next milestone Oct 9, 2026
ReadLocalConfig and ReadLocalWatchConfig returned a plain fmt.Errorf
for a malformed config file instead of going through errors.Wrap like
the rest of pkg/*. Per documentation/error-handling.md, a malformed
local input file is errors.KindUsage, so wrap it that way and assert
the kind in TestReadMalformedConfig.

Signed-off-by: Sarthak <sarthakshreshtha345@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: YAML parse error in config is silently swallowed, login overwrites all other contexts

5 participants