-
-
Notifications
You must be signed in to change notification settings - Fork 4
Fix automatic webhooks #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix automatic webhooks #130
Conversation
for more information, see https://pre-commit.ci
for more information, see https://pre-commit.ci
Where are you importing this? In an The built-in handlers for installation events are automatically loaded by the library's own The pattern for custom handlers is documented here (see the All that said, if the docs gave you the impression you needed to manually import the built-in handlers, that's a gap worth addressing.
Can you describe what you actually tried? What does your project structure look like, and what was the failure mode? (e.g., webhooks received but handlers not called, errors in logs, nothing happening, etc.)
The I'm open to reconsidering whether this is the right architecture. The signals-style pattern works, but it's clearly not obvious from the docs or API. This library emerged from an internal work project and I basically just went with the first obvious idea with an existing Django convention.
The test creates a new |
|
I should also note, this sounds related to #116, which I also haven't been able to reproduce or gotten any clarification from the issue reporter about. If you (or @jensenbox) could provide a minimal reproduction or more details about your Django project structure, that would really help me understand what's going wrong. |
|
So, after poking around, writing a repro of my own from what I could glean from your PR description -- I think there is a timing issue related to the module-level I'll cut a new release here at some point in the next little bit, if you could install and give that version a try (v0.10.0 since I had an existing new unreleased feature) and let me know! I'm going to go ahead and close this for the time being, feel free to re-open (or open an issue) if that doesn't fix your issue. |
I want to ping back on #99 and #100 and #101
My expectations from reading the documentation was that if I imported
from django_github_app.events.installation import ghthen the handler would be automagically installed.From that moment on, any new installation received over webhook would trigger the whole flow adding installation and repository.
I was not able to reproduce this.
I track down the issue to the
GitHubRouterand how it interact with theWebhookViews.My understanding is that the whole
GitHubRouteris suppose to be a singleton in this architecture, and my lead here is the_routersdefined as class member.However, this doesn't quite work as expected. Mostly because the
fetchmethod of theGitHubRoutercompletely ignores the_routersmethod and act only on itself.This can be verified by the test:
tests/test_routing.py::TestGitHubRouter::test_importing_module_add_handleradded in this PR.The test fail as it is.
The solution that I see would it be to update the GitHubRouter::fetch method.
This pass the new test.
However, the new tests fails when we run the whole battery of tests.
I trace this back to a failure when the new tests runs together with the
tests/events/test_installation.py.A dive a bit deeper and the failure happens whenever we import
django_github_app.events.installationin the tests.Didn't have time to investigate further.