fix(brother-ql): doppelter 'preflight SNMP failed' Prefix vermieden#114
Conversation
…Issue #105) query_preflight() in snmp_helper.py erzeugt SnmpQueryError-Messages die bereits mit "preflight SNMP failed: " beginnen. BrotherQLBackend hat denselben Prefix nochmal vorangestellt, was zu doppelten Error-Messages führte ("preflight SNMP failed: preflight SNMP failed: …"). Fix: prüft ob der Prefix bereits vorhanden ist, bevor er hinzugefügt wird. Refs #105 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! Diese Pull Request behebt ein Problem, bei dem Fehlermeldungen des BrotherQLBackend redundant formatiert wurden. Durch die Überprüfung des bestehenden Fehler-Strings wird sichergestellt, dass das Präfix 'preflight SNMP failed' nur einmalig in der finalen Exception erscheint, was die Lesbarkeit der Logs verbessert. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request addresses Issue #105 by preventing duplicate 'preflight SNMP failed' prefixes in PrinterOfflineError messages when handling SnmpQueryError in the Brother QL backend, and adds a corresponding unit test. The review feedback suggests a more robust prefix check (checking for 'preflight SNMP' instead of 'preflight SNMP failed:') to handle other potential error message variations and avoid duplicate prefixes.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| msg = str(exc) | ||
| if not msg.startswith("preflight SNMP failed:"): | ||
| msg = f"preflight SNMP failed: {msg}" | ||
| raise PrinterOfflineError(msg) from exc |
There was a problem hiding this comment.
Wenn query_preflight() einen SnmpQueryError mit einer Nachricht wie "preflight SNMP returned error: ..." wirft, startet diese nicht mit "preflight SNMP failed:". Dadurch wird die Fehlermeldung zu "preflight SNMP failed: preflight SNMP returned error: ..." formatiert, was ein doppeltes "preflight SNMP"-Präfix erzeugt.
Eine robustere Prüfung wäre es, auf "preflight SNMP" zu prüfen, um jegliche doppelte Präfixe für alle von query_preflight() geworfenen Fehler zu vermeiden.
| msg = str(exc) | |
| if not msg.startswith("preflight SNMP failed:"): | |
| msg = f"preflight SNMP failed: {msg}" | |
| raise PrinterOfflineError(msg) from exc | |
| msg = str(exc) | |
| if not msg.startswith("preflight SNMP"): | |
| msg = f"preflight SNMP failed: {msg}" | |
| raise PrinterOfflineError(msg) from exc |
There was a problem hiding this comment.
Pull request overview
Diese Änderung behebt ein kosmetisches Problem in der Fehlerbehandlung des BrotherQLBackend: Wenn query_preflight() bereits eine SnmpQueryError-Message mit dem Prefix preflight SNMP failed: liefert, soll BrotherQLBackend.preflight_check() diesen Prefix nicht nochmals voranstellen (verhindert Meldungen wie preflight SNMP failed: preflight SNMP failed: …). Das passt zur in Issue #105 beschriebenen Phase-1j-Qualitätsbereinigung.
Changes:
- Entdoppelt den
preflight SNMP failed:Prefix inBrotherQLBackend.preflight_check()durch einestartswith(...)-Prüfung. - Fügt einen Unit-Test hinzu, der den Doppel-Prefix-Fall reproduziert und sicherstellt, dass die Message den Prefix nur einmal enthält.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| backend/app/printer_backends/brother_ql_backend.py | Verhindert doppeltes Prefixing der PrinterOfflineError-Message bei bereits präfixierten SnmpQueryErrors. |
| backend/tests/unit/printer_backends/test_brother_ql_backend.py | Ergänzt einen Regressionstest für den bereits-präfixierten SNMP-Fehlerfall (Issue #105). |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #114 +/- ##
==========================================
+ Coverage 89.18% 89.21% +0.03%
==========================================
Files 91 91
Lines 4243 4246 +3
Branches 365 366 +1
==========================================
+ Hits 3784 3788 +4
Misses 360 360
+ Partials 99 98 -1
... and 1 file with indirect coverage changes
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
## <small>0.10.1 (2026-06-10)</small> * fix(brother-ql): doppelter 'preflight SNMP failed' Prefix vermieden (Issue #105) (#114) ([e459fd7](e459fd7)), closes [#105](#105) [#114](#114) [#105](#105) * fix(examples): aktualisiere compose.pangolin.yml und .env.example auf aktuelle Konfiguration (#113) ([a16643e](a16643e)), closes [#113](#113) [#73](#73) * chore(deps): bump the go-minor-and-patch group across 1 directory with 3 updates (#112) ([3939741](3939741)), closes [#112](#112) * docs: Phase 1k.1 Layout-Engine + TapeGeometry + ContentTypes (Spec + Plan) (#108) ([a5425a5](a5425a5)), closes [#108](#108) [#103](#103) [#108](#108) [#103](#103) [#103](#103) [#103](#103) [#103](#103) [#103](#103) [#103](#103) [#103](#103) [#103](#103) [#103](#103) * ci(deps): bump codecov/codecov-action in the actions-all group (#111) ([2a9454b](2a9454b)), closes [#111](#111) [skip ci]
Summary
preflight SNMP failedPrefix inPrinterOfflineErrorMessagesquery_preflight()insnmp_helper.pywirft bereitsSnmpQueryError("preflight SNMP failed: …")— BrotherQLBackend hat denselben Prefix nochmal hinzugefügtCloses #105
Test plan
test_preflight_check_no_duplicate_prefix_when_snmp_error_already_has_prefixschlägt vor dem Fix fehl (TDD Red → bestätigt Bug)test_preflight_check_raises_offline_on_snmp_errorund alle anderen weiterhin grün🤖 Generated with Claude Code