Skip to content

Conversation

@3nprob
Copy link

@3nprob 3nprob commented Jul 5, 2025

resolve1.Get dbus call is not guaranteed to return a list. This handles the case of a None result as equal to [].

An alternative would be to fall back to get_dns_resolv_conf (as already done for handling known errors)

@3nprob 3nprob marked this pull request as ready for review July 5, 2025 06:01
@codecov
Copy link

codecov bot commented Jul 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.10%. Comparing base (e5d626b) to head (3dbe9c3).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #593   +/-   ##
=======================================
  Coverage   71.10%   71.10%           
=======================================
  Files           3        3           
  Lines         481      481           
=======================================
  Hits          342      342           
  Misses        139      139           

☔ View full report in Codecov by Sentry.
📢 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.

@marmarek
Copy link
Member

marmarek commented Jul 6, 2025

According to the documentation DNS is an array, not "array or nothing". Even if I unset all addresses, I still get an array. What is the case when the service does respond with something else? Note the service not responding at all is already handled via an exception.

@3nprob
Copy link
Author

3nprob commented Jul 6, 2025

According to the documentation DNS is an array, not "array or nothing". Even if I unset all addresses, I still get an array. What is the case when the service does respond with something else? Note the service not responding at all is already handled via an exception.

While as you note the dbus interface itself always returns an arrary, dbus-python typings indicate Nothing being a possible return value for the (soft-deprecated) Python API. I didn't look into under what conditions that may happen or if the interface is just mistyped. Seems sane to cover the cases specified by API surface in any case?

@3nprob
Copy link
Author

3nprob commented Jul 6, 2025

The ambiguity makes me think maybe the None case should be handled like known error (falling back to resolv.conf).

Updated accordingly.

@3nprob 3nprob force-pushed the handle-empty-dns-dbus branch from 607b3d7 to 78c36d2 Compare July 6, 2025 02:26
@3nprob 3nprob changed the title fix(qubes-setup-dnat-to-ns): handle null dns debus response as empty fix(qubes-setup-dnat-to-ns): handle null dns dbus response Jul 6, 2025
@3nprob 3nprob force-pushed the handle-empty-dns-dbus branch 2 times, most recently from 55f78e5 to 633271c Compare July 6, 2025 02:58
return nameservers

def get_dns_resolved():
dns = []
Copy link
Member

Choose a reason for hiding this comment

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

This line isn't needed - there is no code path that leave dns unset and gets to the place where it's used. And there would be - better get an exception that is easy to find, than silently break DNS.

Copy link
Author

Choose a reason for hiding this comment

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

And there would be - better get an exception that is easy to find, than silently break DNS.

Hum, the fallback function get_resolv_conf does seem to use the strategy of "fail silently and return empty on error (which does seem sane as there is no global exception handler or hook to catch such errors right now?)

Copy link
Member

Choose a reason for hiding this comment

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

That may want fixing too, at some point (if not propagate exception, then at least log a message)... But that's independent of this PR.

python typings indicate that resolve1.Get may return None.

Handle this possibility as failure, falling back to resolv.conf
@3nprob 3nprob force-pushed the handle-empty-dns-dbus branch from 633271c to 3dbe9c3 Compare July 6, 2025 03:13
@marmarek marmarek merged commit 3dbe9c3 into QubesOS:main Jul 6, 2025
5 checks passed
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.

2 participants