fix(cosmic_config): Make get_local return key_path() error#948
Draft
fix(cosmic_config): Make get_local return key_path() error#948
get_local return key_path() error#948Conversation
It looks like this was changed to be like this in cd8f4ee. But `key_path()` only seems to return `Error::NoConfigDirectory` or `Error::InvalidName`, so it seems reasonable to just update `get()` to also check for `NoConfigDirectory`. (`get_local()` doesn't seem to be used elsewhere, so I don't see nay issues this can cause.)
ids1024
added a commit
to pop-os/cosmic-settings-daemon
that referenced
this pull request
Aug 22, 2025
As noted in pop-os/cosmic-comp#1603, there's no need to a system default config file for this particular setting. So as an alternative to that PR, we can ensure this isn't printed as an error. As noted in the description of pop-os/libcosmic#948, if the system default is not present, `Error::GetKey` is returned, without mapping to the `Error::NotFound` variant. So check for that, as well as `.is_err()`.
ids1024
added a commit
that referenced
this pull request
Aug 22, 2025
Like pop-os/cosmic-settings-daemon#100. We don't appear to install default configs for these settings anywhere? And we may not want libcosmic to inherently depend on globally installed config files. So just avoid printing errors in that case. We may want to consider what errors `ConfigGet` returns (#948) but this should do for now. This should help with a big part of the log spam libcosmic is currently producing.
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.
It looks like this was changed to be like this in cd8f4ee. But
key_path()only seems to returnError::NoConfigDirectoryorError::InvalidName, so it seems reasonable to just updateget()to also check forNoConfigDirectory. (get_local()doesn't seem to be used elsewhere, so I don't see nay issues this can cause.)It's also a bit odd that
get_default()doesn't map errors toNotFound. I guessis_err()should returntrueif the default config doesn't exist, since (at least for some settings) it's important to have default configurations present? But thenget_system_default()could returnNoConfigDirectoryfrom the.default_path()call, which has the same issue...Also, maybe using
is_file(), then reading the file, is racy. Not that it should matter that much, but just checking for not found errors from theread_to_stringcall is probably sufficient.Leaving as a draft while considering these other issues.