Skip to content

fix(client): handle REST session creation failures - #408

Merged
drslebedev merged 1 commit into
mainfrom
fix_dns
Aug 13, 2026
Merged

fix(client): handle REST session creation failures#408
drslebedev merged 1 commit into
mainfrom
fix_dns

Conversation

@drslebedev

Copy link
Copy Markdown
Contributor

A deployed OpenDigitizer service terminated when the hostname configured through DIGITIZER_HOSTNAME was unavailable or could not be resolved.

OpenDigitizer uses DnsClient to register its signals through a REST SET request. When hostname resolution failed, ensureSession() returned an error, but the REST client accessed the result with session.value() without checking it first. This threw
std::bad_expected_access<std::string> from the REST worker thread and terminated the entire OpenDigitizer process.

Changes

  • Check REST session creation results for GET and SET requests.
  • Return session-creation failures through the command callback instead of throwing.
  • Use gai_strerror() for getaddrinfo() error codes.
  • Log DnsClient query, registration, and unregistration failures conditionally.
  • Add a regression test verifying that the same RestClient remains usable after a hostname-resolution failure.

Guard GET and SET requests before accessing failed REST sessions so
hostname-resolution errors are returned through the command callback
without terminating the worker.

Use gai_strerror for resolver errors, add conditional DnsClient failure
logging, and verify that the same RestClient remains usable afterward.

Signed-off-by: drslebedev <dr.s.lebedev@gmail.com>
@drslebedev
drslebedev temporarily deployed to configure coverage August 13, 2026 11:41 — with GitHub Actions Inactive
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 18.18182% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 49.27%. Comparing base (7fb8851) to head (59d51eb).
⚠️ Report is 10 commits behind head on main.

Files with missing lines Patch % Lines
src/services/include/services/dns_client.hpp 0.00% 3 Missing and 3 partials ⚠️
src/client/include/RestClientNative.hpp 50.00% 0 Missing and 2 partials ⚠️
src/rest/include/rest/RestUtils.hpp 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #408      +/-   ##
==========================================
+ Coverage   49.07%   49.27%   +0.19%     
==========================================
  Files          78       78              
  Lines        9870     9968      +98     
  Branches     3727     3767      +40     
==========================================
+ Hits         4844     4912      +68     
+ Misses       2865     2859       -6     
- Partials     2161     2197      +36     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)
B Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

client::Command invalidRequest;
invalidRequest.command = mdp::Command::Set;
invalidRequest.clientRequestID = opencmw::IoBuffer("unresolvable");
invalidRequest.topic = URI<>("http://opencmw-rest-client-test.invalid:12345/dns");
@drslebedev
drslebedev merged commit 9fccd94 into main Aug 13, 2026
23 of 27 checks passed
@drslebedev
drslebedev deleted the fix_dns branch August 13, 2026 12:21
RalphSteinhagen pushed a commit to fair-acc/opendigitizer that referenced this pull request Aug 13, 2026
Bump OpenCMW to include fair-acc/opencmw-cpp#408 so hostname resolution
failures no longer terminate OpenDigitizer.

Skip empty DNS registration and unregistration requests.

Signed-off-by: drslebedev <dr.s.lebedev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants