Skip to content

fix(someip): fail fast when opensomeip native extension is unavailable#629

Open
vtz wants to merge 2 commits intojumpstarter-dev:mainfrom
vtz:fix/someip-fail-fast-native-ext
Open

fix(someip): fail fast when opensomeip native extension is unavailable#629
vtz wants to merge 2 commits intojumpstarter-dev:mainfrom
vtz:fix/someip-fail-fast-native-ext

Conversation

@vtz
Copy link
Copy Markdown
Contributor

@vtz vtz commented Apr 22, 2026

Closes #628

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 22, 2026

Warning

Rate limit exceeded

@vtz has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 55 minutes and 20 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 55 minutes and 20 seconds.

⌛ 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.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 94ce1553-c8e2-4519-bd7c-a5e7751ec9e2

📥 Commits

Reviewing files that changed from the base of the PR and between af18e2c and daa42fd.

📒 Files selected for processing (2)
  • python/packages/jumpstarter-driver-someip/jumpstarter_driver_someip/driver.py
  • python/packages/jumpstarter-driver-someip/jumpstarter_driver_someip/driver_test.py
📝 Walkthrough

Walkthrough

The changes add a runtime precondition check in the SOME/IP driver to validate that the OpenSOME/IP C++ native extension is available at initialization. If the extension is unavailable, a RuntimeError is raised with diagnostic guidance. Supporting test fixtures and error-path test coverage are added to ensure the guard functions correctly.

Changes

Cohort / File(s) Summary
Test Configuration
jumpstarter_driver_someip/conftest.py
Added patch import and _mock_get_ext autouse fixture to mock get_ext() to return a valid object, allowing all tests in this module to bypass the native-extension availability check.
Driver Implementation
jumpstarter_driver_someip/driver.py
Added get_ext import from opensomeip._bridge and a runtime precondition in SomeIp.__post_init__() that raises RuntimeError with guidance if get_ext() returns None (indicating the C++ extension is unavailable).
Error-Path Test
jumpstarter_driver_someip/driver_test.py
Added test_someip_raises_when_native_extension_unavailable unit test that patches get_ext() to return None and verifies that SomeIp initialization raises a RuntimeError with a message matching C\+\+ extension.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • PR #391 — Originally introduced the SOME/IP driver package and its core structure, including driver.py and conftest.py.
  • PR #621 — Modifies the same SomeIp.__post_init__() method to add remote endpoint configuration handling.

Suggested reviewers

  • raballew
  • mangelajo

Poem

🐰 Hops with glee, the native guard stands tall,
No more silent stubs that give us nothing at all!
When extensions vanish, we raise our flag high,
With a message so clear: "C++ cannot fly."
Now SOME/IP knows the truth from the start, 🎯

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix(someip): fail fast when opensomeip native extension is unavailable' clearly and specifically describes the main change—adding validation in SomeIp.post_init() to raise an error if the C++ extension is unavailable.
Description check ✅ Passed The description 'Closes #628' is concise and directly related to the changeset, referencing the linked issue that documents the bug being fixed.
Linked Issues check ✅ Passed All coding requirements from #628 are met: SomeIp.post_init() validates native extension availability via get_ext() and raises RuntimeError with guidance when unavailable [#628]; conftest.py patches get_ext for tests [#628]; and a new error-path unit test verifies the RuntimeError is raised [#628].
Out of Scope Changes check ✅ Passed All changes are in-scope: driver.py adds native extension validation, conftest.py adds test mocking, and driver_test.py adds an error-path unit test—all directly addressing #628's requirement to fail fast when the native extension is unavailable.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

Copy link
Copy Markdown
Contributor

@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.

🧹 Nitpick comments (3)
python/packages/jumpstarter-driver-someip/jumpstarter_driver_someip/driver_test.py (1)

348-351: Test interaction with the autouse _mock_get_ext fixture.

The @patch(...) decorator here is applied after the autouse fixture's patch(...) context enters, so the decorator's patch wins for the duration of the test and restores correctly on exit — good. One small strengthening: also assert the message mentions _opensomeip (the concrete symbol users will grep for) in addition to C++ extension, so a future reword of the generic phrase doesn't silently drop the actionable symbol name. Optional.

Optional tightening
-    with pytest.raises(RuntimeError, match="C\\+\\+ extension"):
+    with pytest.raises(RuntimeError, match=r"_opensomeip.*not available"):
         SomeIp(host="127.0.0.1", port=30490)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@python/packages/jumpstarter-driver-someip/jumpstarter_driver_someip/driver_test.py`
around lines 348 - 351, The test
test_someip_raises_when_native_extension_unavailable should assert the
RuntimeError message mentions the concrete symbol users will grep for; update
the pytest.raises match to include both "C++ extension" and "_opensomeip" (e.g.,
a regex that contains both substrings) so when SomeIp(host="127.0.0.1",
port=30490) raises due to the patched get_ext returning None the assertion
verifies the actionable symbol name _opensomeip is present in the error message.
python/packages/jumpstarter-driver-someip/jumpstarter_driver_someip/driver.py (2)

96-103: Guard looks good; fails fast with actionable guidance.

Placement after transport-mode validation and before any ClientConfig/Endpoint construction is correct, and the error message points users to the concrete macOS rebuild fix from issue #628. Nit: the message is macOS-specific—Linux users hitting e.g. a glibc/ABI mismatch will still see the macOS hint. Consider prefixing with "On macOS:" or linking to the troubleshooting doc referenced in the PR description so non-macOS failures don't look like they need macOS-only steps.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@python/packages/jumpstarter-driver-someip/jumpstarter_driver_someip/driver.py`
around lines 96 - 103, The RuntimeError message raised when get_ext() is None in
driver.py is macOS-specific and may confuse Linux users; update the message in
the get_ext() guard (the raise RuntimeError block) to prefix the macOS-specific
rebuild instruction with "On macOS:" and optionally append a short
cross-reference like "See troubleshooting documentation for other platforms." so
non-macOS failures aren't misdirected; keep the actionable rebuild command and
overall wording intact.

10-10: Consider wrapping the private API import in a try/except for robustness.

_bridge is a private submodule of opensomeip, so get_ext is not part of the public contract and could change upstream. While the code already defensively checks if get_ext() is None, wrapping the import in try/except ImportError would make the driver more resilient to upstream refactors. This way, if opensomeip's internal structure changes, the driver gracefully fails at import time with a clear error rather than a silent function lookup failure.

Note: HAS_NATIVE is not exposed in opensomeip's public API, so the try/except approach is the recommended pattern for now.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@python/packages/jumpstarter-driver-someip/jumpstarter_driver_someip/driver.py`
at line 10, Wrap the private import "from opensomeip._bridge import get_ext" in
a try/except ImportError block so import failures don't raise at module import
time; on ImportError define a safe fallback for get_ext (e.g. a callable that
returns None) so existing checks like "if get_ext() is None" continue to work
and the module degrades gracefully; update any related initialization that
relies on HAS_NATIVE/get_ext to use the fallback and optionally log the import
failure for diagnostics.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@python/packages/jumpstarter-driver-someip/jumpstarter_driver_someip/driver_test.py`:
- Around line 348-351: The test
test_someip_raises_when_native_extension_unavailable should assert the
RuntimeError message mentions the concrete symbol users will grep for; update
the pytest.raises match to include both "C++ extension" and "_opensomeip" (e.g.,
a regex that contains both substrings) so when SomeIp(host="127.0.0.1",
port=30490) raises due to the patched get_ext returning None the assertion
verifies the actionable symbol name _opensomeip is present in the error message.

In
`@python/packages/jumpstarter-driver-someip/jumpstarter_driver_someip/driver.py`:
- Around line 96-103: The RuntimeError message raised when get_ext() is None in
driver.py is macOS-specific and may confuse Linux users; update the message in
the get_ext() guard (the raise RuntimeError block) to prefix the macOS-specific
rebuild instruction with "On macOS:" and optionally append a short
cross-reference like "See troubleshooting documentation for other platforms." so
non-macOS failures aren't misdirected; keep the actionable rebuild command and
overall wording intact.
- Line 10: Wrap the private import "from opensomeip._bridge import get_ext" in a
try/except ImportError block so import failures don't raise at module import
time; on ImportError define a safe fallback for get_ext (e.g. a callable that
returns None) so existing checks like "if get_ext() is None" continue to work
and the module degrades gracefully; update any related initialization that
relies on HAS_NATIVE/get_ext to use the fallback and optionally log the import
failure for diagnostics.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b5fd2f3b-cc2b-456c-b87d-e7cd97c1e4a8

📥 Commits

Reviewing files that changed from the base of the PR and between d6ffbf3 and af18e2c.

📒 Files selected for processing (3)
  • python/packages/jumpstarter-driver-someip/jumpstarter_driver_someip/conftest.py
  • python/packages/jumpstarter-driver-someip/jumpstarter_driver_someip/driver.py
  • python/packages/jumpstarter-driver-someip/jumpstarter_driver_someip/driver_test.py

- Wrap private opensomeip._bridge import in try/except ImportError
- Add cross-platform guidance to the RuntimeError message
- Tighten test assertion regex to match _opensomeip symbol name

Made-with: Cursor
@mangelajo
Copy link
Copy Markdown
Member

@vtz not passing type checking or linter, you can run them locally with "make ty" or "make lint"

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.

bug(someip): RPC responses and events have empty payloads when opensomeip native extension is unavailable

2 participants