fix: lazily create APRSDClient in APRSDFilterThread - #311
Merged
Merged
Conversation
APRSDFilterThread.__init__ eagerly constructed APRSDClient(), which raises MissingConfigOptionException when the aprs_network driver is enabled (default) but not configured. This made it impossible to construct filter-thread subclasses in unconfigured/test environments even when the subclass never decodes packets, breaking third-party plugins that subclass APRSDFilterThread (e.g. aprsd-mqtt-plugin's MQTTRawPlugin, aprsd-webchat-extension's WebChatProcessPacketThread). Create the client lazily in loop() instead, matching the existing APRSDRXThread pattern. Add a regression test asserting the thread can be constructed without a configured client.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
APRSDFilterThread.__init__eagerly constructsAPRSDClient(), which raisesMissingConfigOptionExceptionwhenever theaprs_networkdriver is enabled (the default) but callsign/password/host are not configured. This made it impossible to construct filter-thread subclasses in unconfigured/test environments even when the subclass never decodes packets.Impact
Broke third-party plugin test suites and construction when these are installed:
aprsd-mqtt-plugin(MQTTRawPluginextendsAPRSDFilterThread; itsloop()never uses the client) — 3 tests failedaprsd-webchat-extension(WebChatProcessPacketThreadextendsAPRSDProcessPacketThread) — 2 tests failedBoth suites pass on aprsd 4.2.4; both fail on master, so this is a regression from commit
274d5af(in 4.3.0/5.0.0/5.0.1, none of which have been released to PyPI yet — 4.2.4 is still the latest published version). It will reach users for the first time with the 5.x release.Fix
Create the client lazily in
loop()(if not self._client: self._client = APRSDClient()), matching the existingAPRSDRXThreadpattern. Construction no longer requires a configured connection.Tests
test_constructor_without_clientintests/threads/test_rx.py