Skip to content

Add exception for legacy v6#206

Draft
CoMPaTech wants to merge 3 commits into
mainfrom
airos_legacy
Draft

Add exception for legacy v6#206
CoMPaTech wants to merge 3 commits into
mainfrom
airos_legacy

Conversation

@CoMPaTech
Copy link
Copy Markdown
Owner

@CoMPaTech CoMPaTech commented May 3, 2026

In addition to #205

Summary by CodeRabbit

  • New Features

    • Added TLS compatibility support for legacy v6 devices, enabling more stable connections with older equipment.
  • Chores

    • Version bumped to 0.6.8a0 and changelog updated with release v0.6.8 (2026-05-26).

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 3, 2026

Warning

Review limit reached

@CoMPaTech, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 56 minutes and 24 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, 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 include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: aed88e5c-1882-4bf7-aed1-365dc9b3d03b

📥 Commits

Reviewing files that changed from the base of the PR and between 6c2f548 and 4a5ed04.

📒 Files selected for processing (1)
  • airos/exceptions.py

Walkthrough

Detect legacy AirOS v6 TLS handshake failures in request handling and raise a new AirOSTLSCompatibilityError; helpers catch and re-raise this exception. Package version bumped to 0.6.8a0 and CHANGELOG updated for v0.6.8.

Changes

TLS Compatibility Error Detection

Layer / File(s) Summary
Exception definition
airos/exceptions.py
New AirOSTLSCompatibilityError exception class extending AirOSDeviceConnectionError for legacy TLS/cipher compatibility issues.
Request path detection & handling
airos/base.py
Added SSLError import, _is_tls_compatibility_error() helper to inspect aiohttp.ClientConnectorSSLError messages and causes, and updated _request_json to catch connector SSL errors and raise AirOSTLSCompatibilityError when patterns match.
Helper propagation
airos/helpers.py
async_get_firmware_data now explicitly catches AirOSTLSCompatibilityError, logs the TLS compatibility error for the host, and re-raises it; imports the new exception.
Version & changelog
pyproject.toml, CHANGELOG.md
Project version updated to 0.6.8a0 and CHANGELOG.md gains a ## [0.6.8] - 2026-05-26 entry with "Introduce TLS adjustment for legacy v6 devices".

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • CoMPaTech/python-airos#70: Also modifies error mapping in _request_json; relates to TLS-specific handling added here.
  • CoMPaTech/python-airos#37: Related to standardizing connection exception types that this PR extends with AirOSTLSCompatibilityError.

Poem

🐰 I sniffed a handshake, old and shy,
A TLS tune that made it cry.
I named the quirk, rang a tiny bell,
Now old v6s can shout and tell.
thump thump 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add exception for legacy v6' directly describes the main change: introducing a new exception class (AirOSTLSCompatibilityError) for legacy v6 device TLS compatibility issues.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch airos_legacy

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.

@codecov
Copy link
Copy Markdown

codecov Bot commented May 3, 2026

Codecov Report

❌ Patch coverage is 22.22222% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.27%. Comparing base (647a615) to head (6c2f548).

Files with missing lines Patch % Lines
airos/base.py 21.42% 11 Missing ⚠️
airos/helpers.py 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #206      +/-   ##
==========================================
- Coverage   86.77%   85.27%   -1.51%     
==========================================
  Files           8        8              
  Lines         756      774      +18     
==========================================
+ Hits          656      660       +4     
- Misses        100      114      +14     

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

Copy link
Copy Markdown

@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: 2

🧹 Nitpick comments (1)
airos/base.py (1)

524-536: 💤 Low value

err.__cause__ inspection is redundant — ClientConnectorSSLError already IS an ssl.SSLError.

ClientConnectorSSLError is declared as class ClientConnectorSSLError(*ssl_error_bases), where ssl_error_bases are (ClientSSLError, ssl.SSLError) — so err itself is an ssl.SSLError. Additionally, aiohttp raises it as raise ClientConnectorSSLError(req.connection_key, exc) from exc, meaning err.__cause__ and err carry the same SSL error information.

The isinstance(err.__cause__, SSLError) branch is therefore always reachable when err.__cause__ is set, but the same string content is already accessible directly on err. You can simplify to a single-stage check using str(err).lower():

♻️ Simplified helper
 def _is_tls_compatibility_error(err: aiohttp.ClientConnectorSSLError) -> bool:
     """Return True for known legacy airOS TLS handshake failures."""
-    if "SSLV3_ALERT_HANDSHAKE_FAILURE" in str(err):
-        return True
-
-    cause = err.__cause__
-    if isinstance(cause, SSLError):
-        message = str(cause).lower()
-        return (
-            "handshake failure" in message or "sslv3 alert handshake failure" in message
-        )
-
-    return False
+    message = str(err).lower()
+    return "sslv3_alert_handshake_failure" in message or "handshake failure" in message
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@airos/base.py` around lines 524 - 536, The helper _is_tls_compatibility_error
currently inspects err.__cause__, which is redundant because
ClientConnectorSSLError already subclasses ssl.SSLError; update the logic to use
the exception text from err directly (e.g., message = str(err).lower()) instead
of checking err.__cause__, keep the existing top-level check for
"SSLV3_ALERT_HANDSHAKE_FAILURE", and then return True if "handshake failure" or
"sslv3 alert handshake failure" appears in message so the function relies on err
itself rather than its __cause__.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@airos/exceptions.py`:
- Around line 52-53: The docstring for class AirOSTLSCompatibilityError (which
subclasses AirOSDeviceConnectionError) contains a typo: "compaitibility" should
be "compatibility"; update the class docstring to read "The device requires
legacy TLS/cipher compatibility." ensuring the corrected spelling is used in
AirOSTLSCompatibilityError.

In `@pyproject.toml`:
- Line 7: Update the version label so the pyproject.toml value and the CHANGELOG
entry match: either change the pyproject.toml version string "version =
\"0.6.6a0\"" to "0.6.6" or edit the CHANGELOG heading "[0.6.6]" to "[0.6.6a0]";
ensure both places use the exact same version token before merging the draft to
avoid PEP 440 sorting issues on PyPI.

---

Nitpick comments:
In `@airos/base.py`:
- Around line 524-536: The helper _is_tls_compatibility_error currently inspects
err.__cause__, which is redundant because ClientConnectorSSLError already
subclasses ssl.SSLError; update the logic to use the exception text from err
directly (e.g., message = str(err).lower()) instead of checking err.__cause__,
keep the existing top-level check for "SSLV3_ALERT_HANDSHAKE_FAILURE", and then
return True if "handshake failure" or "sslv3 alert handshake failure" appears in
message so the function relies on err itself rather than its __cause__.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 96ea020f-dfd4-4676-941b-887445d30ab9

📥 Commits

Reviewing files that changed from the base of the PR and between 615c67a and 39b9ed9.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • airos/base.py
  • airos/exceptions.py
  • pyproject.toml

Comment thread airos/exceptions.py Outdated
Comment thread pyproject.toml Outdated
[project]
name = "airos"
version = "0.6.5"
version = "0.6.6a0"
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Version label in pyproject.toml (0.6.6a0) doesn't match the CHANGELOG entry ([0.6.6]).

0.6.6a0 is a PEP 440 alpha pre-release. PyPI will sort it below 0.6.6. Since this is a draft, the a0 suffix is likely a work-in-progress marker, but the CHANGELOG entry (Line 5) should align — either record [0.6.6a0] there, or drop the suffix in pyproject.toml before the PR graduates from draft.

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

In `@pyproject.toml` at line 7, Update the version label so the pyproject.toml
value and the CHANGELOG entry match: either change the pyproject.toml version
string "version = \"0.6.6a0\"" to "0.6.6" or edit the CHANGELOG heading
"[0.6.6]" to "[0.6.6a0]"; ensure both places use the exact same version token
before merging the draft to avoid PEP 440 sorting issues on PyPI.

Copy link
Copy Markdown

@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 (1)
airos/helpers.py (1)

42-44: 💤 Low value

Redundant logging of TLS compatibility error.

The exception is already logged in base.py (_request_json) before being raised. This handler logs the same error again, resulting in duplicate log entries for a single failure.

Consider removing the logging here since the exception already carries the context, or keeping only one log site for clarity.

♻️ Proposed fix to remove redundant logging
     except AirOSTLSCompatibilityError:
-        _LOGGER.exception("TLS compatibility error during API call to %s", host)
         raise
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@airos/helpers.py` around lines 42 - 44, The except block for
AirOSTLSCompatibilityError in airos/helpers.py is redundantly logging the same
error already logged by _request_json in base.py; remove the
_LOGGER.exception("TLS compatibility error during API call to %s", host) line
and leave only the raise so the exception bubbles up (preserving original
context from _request_json), referencing the AirOSTLSCompatibilityError handler
in airos/helpers.py and the _request_json logging in base.py to locate the
duplicate log site.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@airos/helpers.py`:
- Around line 42-44: The except block for AirOSTLSCompatibilityError in
airos/helpers.py is redundantly logging the same error already logged by
_request_json in base.py; remove the _LOGGER.exception("TLS compatibility error
during API call to %s", host) line and leave only the raise so the exception
bubbles up (preserving original context from _request_json), referencing the
AirOSTLSCompatibilityError handler in airos/helpers.py and the _request_json
logging in base.py to locate the duplicate log site.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: c957ef3d-51a2-4701-a08b-618983523bab

📥 Commits

Reviewing files that changed from the base of the PR and between 39b9ed9 and 6c2f548.

📒 Files selected for processing (5)
  • CHANGELOG.md
  • airos/base.py
  • airos/exceptions.py
  • airos/helpers.py
  • pyproject.toml
✅ Files skipped from review due to trivial changes (1)
  • pyproject.toml

@sonarqubecloud
Copy link
Copy Markdown

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.

1 participant