Skip to content

Conversation

@mulkieran
Copy link
Member

@mulkieran mulkieran commented Nov 26, 2025

No description provided.

@mulkieran mulkieran self-assigned this Nov 26, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 26, 2025

Warning

Rate limit exceeded

@mulkieran has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 21 minutes and 45 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 6ecf3e8 and 7f100ed.

📒 Files selected for processing (1)
  • src/stratis_cli/_error_reporting.py (12 hunks)

Walkthrough

Adds explicit type hints to functions in src/stratis_cli/_error_reporting.py; centralizes error-interpretation orchestration; caches D-Bus name lookups; and adds branches for missing GetManagedObjects properties and property-retrieval failures, with functions returning Optional[str].

Changes

Cohort / File(s) Summary
Error reporting refactor
src/stratis_cli/_error_reporting.py
Adds typing imports and type hints (e.g., List, Optional, BaseException, dbus.exceptions.DBusException); updates signatures for _interface_name_to_common_name, _interpret_errors_0, _interpret_errors_1, _interpret_errors_2, _interpret_errors, and handle_error to explicit types and Optional[str]; caches dbus_name in _interpret_errors_0; expands logic to handle missing GetManagedObjects properties and DPClient property-retrieval failures; centralizes orchestration and fallback logic.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Files/areas to pay attention to:
    • _interpret_errors_1: KeyError inspection and composed message for missing GetManagedObjects properties
    • _interpret_errors_2: extraction and interpretation of DPClientGetPropertyContext and property-failure messaging
    • _interpret_errors_0: correct use/caching of dbus_name and DBusException typing
    • Call sites of _interpret_errors / handle_error to ensure they accept Optional[str]

Poem

🐇
I sniffed the bus where errors hide,
I labeled names and cached their stride.
When props went missing, I wrote the clue,
A rabbit's patch — now logs read true. 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Add additional pattern matches for error recognition' is vague and does not clearly reflect the main changes, which involve adding type hints and expanding error handling logic in the error reporting module. Revise the title to more specifically describe the changes, such as 'Add type hints to error handling functions and expand error pattern matching' or 'Enhance error reporting with type annotations and detailed error messages'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mulkieran mulkieran changed the title Recognize failed dbus name Add additional pattern matches for error recognition Nov 26, 2025
@mulkieran mulkieran moved this to In Review in 2025November Nov 26, 2025
@mulkieran mulkieran moved this from In Review to In Progress in 2025November Nov 26, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
src/stratis_cli/_error_reporting.py (2)

185-203: KeyError-based message is helpful; consider guarding against empty KeyError.args

The new branch that inspects a secondary KeyError and emits a property-specific message is a nice improvement in diagnostics, especially the inclusion of the interface and property name.

One small robustness tweak you might consider: if KeyError were ever raised without arguments, maybe_key_error.args[0] would itself raise an IndexError. A defensive pattern would be something like:

-            if isinstance(maybe_key_error, KeyError):
-                return (
-                    f'Property "{maybe_key_error.args[0]}" belonging to '
+            if isinstance(maybe_key_error, KeyError):
+                prop_name = maybe_key_error.args[0] if maybe_key_error.args else "<?>"
+                return (
+                    f'Property "{prop_name}" belonging to '
                     f'interface "{error.interface_name}" is not in this '
                     "GetManagedObjects result. This could be due to the fact "
                     "that stratisd omitted the property from the "
                     "GetManagedObjects result because there was an error in "
                     "obtaining that value."
                 )

Not strictly necessary if you fully control the KeyError construction, but it hardens this path against unexpected call sites.


263-335: New GetProperty-context handling under DBus.Error.Failed is consistent and precise

The addition of the pylint too-many-return-statements suppression on _interpret_errors_2 is appropriate given the pattern-matching style here.

The new DPClientGetPropertyContext branch under the org.freedesktop.DBus.Error.Failed case mirrors the existing SetProperty handling and gives a clear, property-specific message including the daemon’s error text. This fits well with the existing interpretations for GetManagedObjects and SetProperty and doesn’t alter behavior for other contexts.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between adf7744 and f6bc3ca.

📒 Files selected for processing (1)
  • src/stratis_cli/_error_reporting.py (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: test-runs (3.12)
  • GitHub Check: test-runs (3.13)
🔇 Additional comments (1)
src/stratis_cli/_error_reporting.py (1)

115-155: Local dbus_name reuse keeps logic unchanged and improves clarity

Using a single dbus_name = error.get_dbus_name() and reusing it for the AccessDenied and NameHasNoOwner/ServiceUnknown checks is a clean refactor: behavior is preserved while avoiding repeated calls and keeping the conditionals easier to read.

@mulkieran mulkieran force-pushed the recognize-failed-dbus-name branch from f6bc3ca to e58bfa6 Compare November 26, 2025 22:10
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/stratis_cli/_actions/_physical.py (1)

134-141: Critical: Table header/data column count mismatch.

The table data now has 6 columns (including the new InitializationTime at lines 134-136), but print_table is called with only 5 headers at line 141. This mismatch will cause display issues or runtime errors.

Apply this diff to add the missing header:

 print_table(
-    ["Pool Name", "Device Node", "Physical Size", "Tier", "UUID"],
+    ["Pool Name", "Device Node", "Physical Size", "Tier", "UUID", "Initialization Time"],
     sorted(tables, key=lambda entry: (entry[0], entry[1])),
-    ["<", "<", ">", ">", "<"],
+    ["<", "<", ">", ">", "<", "<"],
 )
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f6bc3ca and e58bfa6.

📒 Files selected for processing (3)
  • src/stratis_cli/_actions/_data.py (1 hunks)
  • src/stratis_cli/_actions/_physical.py (2 hunks)
  • src/stratis_cli/_error_reporting.py (5 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/stratis_cli/_error_reporting.py
🧰 Additional context used
🧬 Code graph analysis (1)
src/stratis_cli/_actions/_physical.py (1)
src/stratis_cli/_actions/_connection.py (1)
  • get_object (44-52)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: test-runs (3.13)
  • GitHub Check: test-runs (3.12)
  • GitHub Check: check-typos
🔇 Additional comments (2)
src/stratis_cli/_actions/_data.py (1)

88-91: LGTM! Good consistency improvement.

Adding the Dev class alongside MODev brings the blockdev interface in line with the existing patterns for filesystem and pool interfaces, where both a direct class and a managed object class are generated.

src/stratis_cli/_actions/_physical.py (1)

49-49: Verify that Dev import is intentionally part of this PR.

The PR title indicates this is about "error recognition," but the changes add device InitializationTime display functionality. Confirm this feature addition is intentional for this PR.

Comment on lines 134 to 136
Dev.Properties.InitializationTime.Get(
get_object("/org/storage/stratis3/1")
),
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: Hardcoded object path yields incorrect per-device values.

The same hardcoded path "/org/storage/stratis3/1" is used for all devices in the loop. This means every device row will display the same InitializationTime value (or an error if that path is invalid), rather than each device's individual InitializationTime.

To retrieve the correct InitializationTime for each device, you need to:

  1. Capture the device object path in the modevs list comprehension (lines 58-73)
  2. Use that object path when calling Dev.Properties.InitializationTime.Get()

Apply this diff to capture device object paths:

 modevs = [
-    MODev(info)
+    (objpath, MODev(info))
     for objpath, info in devs(
         props=(
             None
             if pool_name is None
             else {
                 "Pool": next(
                     pools(props={"Name": pool_name})
                     .require_unique_match(True)
                     .search(managed_objects)
                 )[0]
             }
         )
     ).search(managed_objects)
 ]

Then update the table building to use per-device paths:

 tables = [
     [
-        path_to_name.get(modev.Pool(), TABLE_UNKNOWN_STRING),
-        paths(modev),
-        size(modev),
-        tier_str(modev.Tier()),
-        format_uuid(modev.Uuid()),
+        path_to_name.get(modev[1].Pool(), TABLE_UNKNOWN_STRING),
+        paths(modev[1]),
+        size(modev[1]),
+        tier_str(modev[1].Tier()),
+        format_uuid(modev[1].Uuid()),
         Dev.Properties.InitializationTime.Get(
-            get_object("/org/storage/stratis3/1")
+            get_object(modev[0])
         ),
     ]
-    for modev in modevs
+    for modev in modevs
 ]

Alternatively, unpack the tuple in the comprehension for cleaner code:

 tables = [
     [
         path_to_name.get(modev.Pool(), TABLE_UNKNOWN_STRING),
         paths(modev),
         size(modev),
         tier_str(modev.Tier()),
         format_uuid(modev.Uuid()),
         Dev.Properties.InitializationTime.Get(
-            get_object("/org/storage/stratis3/1")
+            get_object(objpath)
         ),
     ]
-    for modev in modevs
+    for objpath, modev in modevs
 ]

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In src/stratis_cli/_actions/_physical.py around lines 58-73 and 134-136, the
code uses a hardcoded object path "/org/storage/stratis3/1" when fetching
InitializationTime for every device; capture each device's actual object path in
the modevs list comprehension (include the object path in the tuple you build
per device or make the comprehension produce (device, object_path) pairs), then
update the table-building code to call
Dev.Properties.InitializationTime.Get(object_path) for that device instead of
the hardcoded string; alternatively unpack the tuple from the comprehension into
(dev, path) for clearer usage when building rows.

@mulkieran mulkieran force-pushed the recognize-failed-dbus-name branch 2 times, most recently from 1e048ac to 719fd24 Compare November 26, 2025 22:47
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
src/stratis_cli/_error_reporting.py (3)

163-205: New handling for DbusClientMissing* with underlying KeyError is good; consider tightening the property name formatting

The added logic that inspects errors[1] for a KeyError and surfaces a message about a missing property in the GetManagedObjects result is a useful improvement and matches the expected chain shape (ActionError -> DbusClientMissing* -> KeyError -> ...).

One small polish: using maybe_key_error.args in the f‑string will render a tuple (e.g. "('PropName',)") for the common single‑argument case. You might want to prefer the first argument when present for a cleaner message, e.g.:

-        if len(errors) > 1:
-            maybe_key_error = errors[1]
-            if isinstance(maybe_key_error, KeyError):
-                return (
-                    f'Property "{maybe_key_error.args}" belonging to '
+        if len(errors) > 1:
+            maybe_key_error = errors[1]
+            if isinstance(maybe_key_error, KeyError) and maybe_key_error.args:
+                return (
+                    f'Property "{maybe_key_error.args[0]}" belonging to '
                     f'interface "{error.interface_name}" is not in this '
                     "GetManagedObjects result. This could be due to the fact "
                     "that stratisd omitted the property from the "
                     "GetManagedObjects result because there was an error in "
                     "obtaining that value."
                 )

This keeps the new behaviour but improves readability of the diagnostic.


362-385: _interpret_errors orchestration is consistent, but empty subchains rely on the broad except

Delegating directly to _interpret_errors_1(errors[1:]) after asserting a StratisCliActionError head matches the docstring (“subchain after the first error”) and works for the usual multi‑element chains.

If an action error somehow has no cause (i.e. errors length is 1), _interpret_errors_1 will see an empty list and raise IndexError, which is then swallowed by the broad except and results in None. That’s safe but a bit indirect; you could optionally guard against this and avoid the extra exception:

-    try:
-        assert isinstance(errors[0], StratisCliActionError)
-
-        return _interpret_errors_1(errors[1:])
+    try:
+        assert isinstance(errors[0], StratisCliActionError)
+        if len(errors) > 1:
+            return _interpret_errors_1(errors[1:])
+        return None

This preserves behaviour but removes reliance on the catch‑all for a predictable edge case.


387-412: Return type of handle_error does not match its behaviour

handle_error is annotated as -> Optional[str], but all paths either raise (raise err) or call exit_, and the function never returns the explanation string to the caller. At runtime this is fine, but the annotation is misleading and may confuse type checkers or readers.

Consider one of:

  • If callers never consume a return value (current behaviour), change the signature to reflect non‑returning semantics, e.g. -> None or -> NoReturn (with from typing import NoReturn).
  • If you intend to surface the explanation for programmatic use, explicitly return explanation instead of calling exit_ directly, and move the exit/printing logic to the caller.

Aligning the annotation with the actual control flow will make the intent clearer and keep static analysis happy.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e58bfa6 and 719fd24.

📒 Files selected for processing (1)
  • src/stratis_cli/_error_reporting.py (11 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: test-runs (3.13)
  • GitHub Check: test-runs (3.12)
🔇 Additional comments (3)
src/stratis_cli/_error_reporting.py (3)

21-72: Type imports and _interface_name_to_common_name annotations look consistent

Importing List/Optional and adding interface_name: str -> str are consistent with current usage and docstrings; no behaviour change or issues here.


101-160: Refactor in _interpret_errors_0 to cache dbus_name is safe

Using a local dbus_name = error.get_dbus_name() and reusing it in the subsequent checks keeps semantics identical while avoiding repeated calls. The existing AccessDenied and NameHasNoOwner/ServiceUnknown handling remains correct.


264-337: Extended _interpret_errors_2 for DPClientGetPropertyContext is coherent with existing patterns

The new branch that detects DPClientGetPropertyContext when the D‑Bus error is org.freedesktop.DBus.Error.Failed mirrors the existing DPClientSetPropertyContext handling and provides a clear, context‑rich message for get‑property failures. Interface and property name usage look correct, and the control flow still falls back to other handlers when no specific context matches.

@mulkieran mulkieran force-pushed the recognize-failed-dbus-name branch from 719fd24 to 674ede4 Compare December 1, 2025 01:00
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/stratis_cli/_error_reporting.py (1)

163-204: Tighter handling of missing property errors; consider refining KeyError formatting

The new branch for DbusClientMissingSearchPropertiesError / DbusClientMissingPropertyError with a following KeyError gives a much more actionable explanation, which is helpful.

One minor improvement: in Line 197, maybe_key_error.args is usually a tuple, so the message will show something like ("prop_name",) rather than just prop_name. Using the first arg or str(maybe_key_error) would read more naturally.

For example:

-            if isinstance(maybe_key_error, KeyError):
-                return (
-                    f'Property "{maybe_key_error.args}" belonging to '
+            if isinstance(maybe_key_error, KeyError):
+                prop_name = maybe_key_error.args[0] if maybe_key_error.args else maybe_key_error
+                return (
+                    f'Property "{prop_name}" belonging to '
                     f'interface "{error.interface_name}" is not in this '
                     "GetManagedObjects result. This could be due to the fact "
                     "that stratisd omitted the property from the "
                     "GetManagedObjects result because there was an error in "
                     "obtaining that value."
                 )

This keeps the new behavior but produces a cleaner user-facing message.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 719fd24 and 674ede4.

📒 Files selected for processing (1)
  • src/stratis_cli/_error_reporting.py (12 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/stratis_cli/_error_reporting.py (1)
src/stratis_cli/_errors.py (1)
  • StratisCliActionError (360-382)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: test-runs (3.12)
  • GitHub Check: test-runs (3.13)
🔇 Additional comments (6)
src/stratis_cli/_error_reporting.py (6)

21-21: Typing imports are consistent with added annotations

Importing List and Optional matches the new function signatures and keeps typing centralized here. No issues.


64-87: Type annotation on _interface_name_to_common_name is appropriate

The interface_name: str -> str signature matches how this helper is used and should improve type checking without altering behavior.


101-160: Refactor of _interpret_errors_0 to use dbus_name and Optional[str] looks good

Caching error.get_dbus_name() into dbus_name reduces repetition and makes the subsequent comparisons clearer, and the Optional[str] return type matches the documented “may return None” behavior. No behavioral regressions apparent.


264-337: New DPClientGetPropertyContext handling is coherent with existing patterns

Extending _interpret_errors_2 to recognize DPClientGetPropertyContext under org.freedesktop.DBus.Error.Failed mirrors the existing DPClientSetPropertyContext handling and yields a clear, targeted explanation about failing to get a property. The use of context.property_name and error.interface_name aligns with the other branches.


362-377: Type annotation and explicit length assertion in _interpret_errors are reasonable

Annotating _interpret_errors as taking List[BaseException] and returning Optional[str] matches its actual usage. The assert len(errors) > 1 makes the expectation that there is at least one underlying cause explicit; any violation is still safely absorbed by the surrounding try/except and results in the generic “unexpected error” path, as before.


388-413: Narrowing handle_error’s parameter type clarifies intent

Typing err as StratisCliActionError documents the precondition already described in the comments and aligns with how get_errors(err) is consumed. The function’s behavior—either raising/printing a generic message or exiting with a specific explanation—remains unchanged.

@mulkieran mulkieran force-pushed the recognize-failed-dbus-name branch from 674ede4 to a1e1fe0 Compare December 1, 2025 01:27
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/stratis_cli/_error_reporting.py (1)

391-416: Optional: Consider adding return type annotation.

The parameter type hint is appropriate. For completeness, you could add -> NoReturn as the return type annotation (requires from typing import NoReturn), since the function either calls exit_() or raises an exception. However, this is purely optional—the function's behavior is clear from its implementation.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 674ede4 and a1e1fe0.

📒 Files selected for processing (1)
  • src/stratis_cli/_error_reporting.py (12 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/stratis_cli/_error_reporting.py (1)
src/stratis_cli/_errors.py (1)
  • StratisCliActionError (360-382)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: test-runs (3.12)
  • GitHub Check: test-runs (3.13)
🔇 Additional comments (6)
src/stratis_cli/_error_reporting.py (6)

21-21: LGTM: Type imports added for function annotations.

The addition of List and Optional from the typing module supports the new type hints throughout the file, improving code clarity and type safety.


64-64: LGTM: Type annotations added.

The type hints correctly document that the function accepts and returns a string.


101-122: LGTM: Good refactor to cache D-Bus name.

The introduction of the dbus_name variable eliminates redundant calls to error.get_dbus_name(), improving efficiency. The type hints accurately reflect the function signature.


186-207: LGTM: Comprehensive handling for missing GetManagedObjects properties.

The new branch effectively handles the case where stratisd omits a property from the GetManagedObjects result due to an error. The logic:

  • Safely checks for a chained KeyError
  • Extracts the property key with appropriate fallback
  • Provides a detailed, actionable error message

The implementation correctly handles edge cases and falls back to the generic message when the specific pattern doesn't match.


332-340: LGTM: Added handling for D-Bus property retrieval failures.

The new branch provides detailed error reporting when getting a D-Bus property fails, maintaining consistency with the existing SetPropertyContext handling. The error message appropriately includes the property name, interface name, and the underlying D-Bus error.


365-381: LGTM: Strengthened precondition check.

The additional assertion ensures that the error chain contains at least one error beyond the initial StratisCliActionError. This prevents potential issues when calling _interpret_errors_1(errors[1:]) and properly handles cases where no interpretable error chain exists.

@mulkieran mulkieran force-pushed the recognize-failed-dbus-name branch 3 times, most recently from 6ecf3e8 to 7f100ed Compare December 1, 2025 03:02
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/stratis_cli/_error_reporting.py (1)

21-21: Type hints look consistent; consider minor annotation/docstring refinements

The added List/Optional imports and annotations on _interface_name_to_common_name, _interpret_errors_0/1/2, and _interpret_errors all line up with how these functions are used and what they return. Two small, optional polish items:

  • handle_error never returns normally (it always raises), so annotating it as NoReturn can help static analysis.
  • Docstrings for _interpret_errors_1/_interpret_errors_2/_interpret_errors still mention “list of Exception” / “None or str”; if you care about strict consistency with type hints, you could update those to match List[BaseException] / Optional[str].

Example diff if you choose to adopt this:

-from typing import List, Optional
+from typing import List, Optional, NoReturn
@@
-def _interpret_errors(errors: List[BaseException]) -> Optional[str]:
+def _interpret_errors(errors: List[BaseException]) -> Optional[str]:
@@
-def handle_error(err: StratisCliActionError):
+def handle_error(err: StratisCliActionError) -> NoReturn:
@@
-    :param errors: the chain of errors
-    :type errors: list of Exception
-    :returns: None if no interpretation found, otherwise str
+    :param errors: the chain of errors
+    :type errors: list of BaseException
+    :returns: None if no interpretation found, otherwise str

(and similarly for the other two functions’ docstrings, if desired).

Also applies to: 64-64, 101-103, 163-165, 267-269, 365-365, 391-391

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a1e1fe0 and 6ecf3e8.

📒 Files selected for processing (1)
  • src/stratis_cli/_error_reporting.py (12 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/stratis_cli/_error_reporting.py (1)
src/stratis_cli/_errors.py (1)
  • StratisCliActionError (360-382)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: test-runs (3.13)
  • GitHub Check: test-runs (3.12)
🔇 Additional comments (4)
src/stratis_cli/_error_reporting.py (4)

101-103: Caching dbus_name improves clarity without changing behavior

Using a local dbus_name = error.get_dbus_name() and then comparing against that value in the AccessDenied and name/owner cases is a clean, behavior‑preserving refactor. It avoids repeated method calls and makes the matching logic easier to follow. No issues spotted here.

Also applies to: 116-137


186-188: New KeyError branch gives a precise GetManagedObjects diagnostic

The additional handling for DbusClientMissingSearchPropertiesError / DbusClientMissingPropertyError when followed by a KeyError in the chain looks solid:

  • You guard on len(errors) > 1 before accessing errors[1].
  • You confirm the second error is a KeyError and safely access args[0] only if present.
  • When the pattern does not match, you still fall back to _DBUS_INTERFACE_MSG, so you preserve existing behavior.

This should yield much more actionable messages for missing properties in GetManagedObjects without introducing new failure modes.

Also applies to: 193-207


267-269: GetProperty context handling is consistent with existing SetProperty branch

The new DPClientGetPropertyContext branch under the DBus.Error.Failed case mirrors the existing DPClientSetPropertyContext messaging:

  • It keys off the same next_error.get_dbus_name() == "org.freedesktop.DBus.Error.Failed" guard.
  • It uses context.property_name and error.interface_name to build a clear, user‑facing explanation.
  • It reuses next_error.get_dbus_message() to surface daemon‑provided detail.

The control flow remains safe: if the context is not a DPClientGetPropertyContext, this branch is skipped and other handling applies as before. No correctness concerns.

Also applies to: 332-340


365-382: Stricter precondition on error chains avoids index errors and centralizes behavior

Tightening _interpret_errors with assert len(errors) > 1 before delegating to _interpret_errors_1(errors[1:]) is a good defensive step:

  • It guarantees _interpret_errors_1 always receives a non‑empty list, preventing an IndexError on errors[0].
  • Violations drop into the broad except and result in None, which in turn drives handle_error down the generic “unexpected error” path — a sensible fallback.

handle_error’s orchestration of get_errors(err), _interpret_errors, and the generic fallback (printing a helpful message and re‑raising when no explanation is found) remains coherent and unchanged in spirit; only the internal precondition and typing were tightened. This looks correct.

Also applies to: 391-416

Signed-off-by: mulhern <amulhern@redhat.com>
Signed-off-by: mulhern <amulhern@redhat.com>
Signed-off-by: mulhern <amulhern@redhat.com>
Signed-off-by: mulhern <amulhern@redhat.com>
@mulkieran mulkieran merged commit 1b58faa into stratis-storage:master Dec 1, 2025
9 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in 2025November Dec 1, 2025
@mulkieran mulkieran deleted the recognize-failed-dbus-name branch December 1, 2025 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant