Skip to content

Conversation

@leplatrem
Copy link
Contributor

Fixes #137
Fixes #136

I could reproduce these issues by:

  • setting up real clients (Bugzilla API key, JIRA API key) in .env
  • running locally with make start
  • checking that clients can connect with http :8000/__heartbeat__

In order to force initialization of actions on the /whiteboard_tags/ endpoint I added this:

 app.include_router(monitor_router)
@@ -109,6 +110,9 @@ def get_whiteboard_tags(
     actions: Actions = Depends(configuration.get_actions),
 ):
     """API for viewing whiteboard_tags and associated data"""
+    for action in actions:
+        assert callable(action.callable)  # will load Python module
+

And then, reaching out /whiteboard_tags/ would crash, trying to serialize:

  1. the action executor class (callable attribute)
  2. the bugzilla client
  3. some internal requests/pool/socket object

I could only fix it by using .dict(exclude={"callable"}) (or using model config and just .dict() as in the present patch)

I failed at reproducing the situation in a unit test (naive version below):

+def test_whiteboard_tags_with_initialized_actions(
+    anon_client, mocked_jira, webhook_create_example
+):
+    assert configuration.get_actions(), "There is at least one configured action"
+    for action in configuration.get_actions():
+        action.callable(webhook_create_example)
+
+    resp = anon_client.get("/whiteboard_tags/")
+    assert resp.status_code == 200  # not crashing :)
+

because the issue comes from an internal urlib object that only gets initialized when session is established

@leplatrem leplatrem requested a review from a team as a code owner July 22, 2022 15:47
@leplatrem leplatrem merged commit d46eb39 into main Jul 22, 2022
@leplatrem leplatrem deleted the 137-whiteboard-tags-crash branch July 22, 2022 16:04
@grahamalama
Copy link
Contributor

Reproduced and verified this fix locally.

We should add an issue to reproduce this through a test (and I still think this can all be done through straight model config), but in the interest of getting this bug fixed, let's get this shipped.

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.

Whiteboard Tags API - 500 Internal Server Error Powered By API - Returning 500

3 participants