Skip to content

fix(utils): report runtime config probe errors - #2124

Open
chennaji9 wants to merge 2 commits into
OpenAtom-Linyaps:masterfrom
chennaji9:fix/runtime-config-probe-errors
Open

chennaji9 wants to merge 2 commits into
OpenAtom-Linyaps:masterfrom
chennaji9:fix/runtime-config-probe-errors

Conversation

@chennaji9

Copy link
Copy Markdown

What does this PR do?

loadRuntimeConfigFromDir probes for config.json and the config.d drop-in directory but ignores the error codes of those probes:

std::error_code ec;
if (std::filesystem::exists(configPath, ec)) { ... }
...
if (std::filesystem::is_directory(configDPath, ec)) { ... }

When the query itself fails — e.g. config.json is a symlink loop (ELOOP) or a parent lost search permission (EACCES) — the probe returns false and the failure is silently treated as "no configuration": the caller gets success with an empty optional instead of an error.

Probe with status() and distinguish real failures from absence:

  • file_type::none (status could not be determined) is reported as a LINGLONG_ERR with the path and ec.message();
  • not_found keeps meaning legitimately absent (POSIX reports an error_code for ENOENT as well, so checking ec directly is not a valid absence test — this is why the fix keys off the status type instead).

Validation

Three new unit tests (using the public loadRuntimeConfig(configDirs, appId, instance) overload):

  • LoadRuntimeConfigWithSymlinkLoop — config.json as a self-referential symlink returns an error;
  • LoadRuntimeConfigWithConfigDSymlinkLoop — config.d as a self-referential symlink returns an error;
  • LoadRuntimeConfigWithoutConfig — empty config dir still returns success with an empty optional (regression guard).

ELOOP is privilege-independent, so the tests behave the same for any user. Full result: ctest -R RuntimeConfig → 29/29 Passed (26 pre-existing + 3 new); ll-tests builds cleanly.

🤖 Generated with Claude Code

@deepin-ci-robot

Copy link
Copy Markdown
Collaborator

Hi @chennaji9. Thanks for your PR.

I'm waiting for a OpenAtom-Linyaps member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@codecov

codecov Bot commented Oct 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
libs/utils/src/linglong/utils/runtime_config.cpp 75.00% 0 Missing and 2 partials ⚠️
Files with missing lines Coverage Δ
libs/utils/src/linglong/utils/runtime_config.cpp 43.41% <75.00%> (+3.57%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

loadRuntimeConfigFromDir ignored the error_code from the config.json
exists() probe and the config.d is_directory() probe, silently reporting
"no configuration" when the check itself failed (e.g. symlink loop or
missing search permission). Check the error codes and return an error,
keeping the legitimate no-config case as success with nullopt, and add
unit tests.

Signed-off-by: 陈那几 <2078634206@qq.com>
exists()/is_directory() report an error_code even for regular ENOENT on
POSIX, so checking ec directly turned every absent config.json/config.d
into a load error. Probe with status() instead: file_type::none means the
status could not be determined (ELOOP, EACCES, ...) and is reported as an
error, while not_found keeps meaning absent.

Signed-off-by: 陈那几 <2078634206@qq.com>
@chennaji9
chennaji9 force-pushed the fix/runtime-config-probe-errors branch from ae0b0cd to e062d08 Compare October 13, 2026 05:46
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.

2 participants