Repository navigation
fix(webhooks): stop returning 500 for Free, Pro and unknown subscription names - #207
Open
gerardosabetta wants to merge 1 commit into
Open
gerardosabetta wants to merge 1 commit into
gerardosabetta wants to merge 1 commit into
Conversation
…ion names SubscriptionChange now removes the subscription role for Free, returns 422 with a warning for a name that has no subscription_labs role, and no longer resolves names against rank or position roles. Refs hackthebox#205 Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
gerardosabetta
requested review from
dimoschi and
makelarisjr
as code owners
November 10, 2026 12:20
Author
This branch has not been deployed
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.






Types of changes
Proposed changes
Refs #205.
POST /webhookwith aSubscriptionChangeevent returned HTTP 500 whenproperties.subscription_namewasFreeorPro, because the handler raisedValueErrorfor any name without a role.subscription_namevip,dedivipFree(any case)subscription_labsrole is removed if they hold oneProProis configuredsubscription_labscategory.get_post_or_rankalso searched position, rank and creator roles, so a name such asHackerresolved to a rank role and then failed the group check.httpxis added to the dev dependency group. The new end-to-end tests use it to call the FastAPI app.Decisions for the reviewer
The issue says the fix needs two product decisions. This PR takes a position on one and leaves the other open:
Freeremoves the subscription role. The alternative is to acknowledge the event and change nothing. That is a one-line change in_NO_ROLE_SUBSCRIPTIONShandling.Prois not mapped in code. After this PR,Proevents get a 422 instead of a 500. They start to succeed when an admin adds asubscription_labsdynamic role with keyPro. IfPromust map to the existingvipordediviprole, say which one and I will add it. This is why the PR says "Refs" and not "Fixes".Checklist
CONTRIBUTING.md asks for an assignee on the issue before a PR is opened. I am not assigned to #205, so I left that box open; close this PR if someone else owns the fix.
Unit tests pass locally: 366 passed on Python 3.13.
flake8reports 12 findings insrc/webhooks/handlers/mp.pyonmainand the same 12 with this change, so I left the lint box open. The new test file has no findings.Additional context
The first commit of this work was a reproduction: a signed request through the real app,
MPHandlerandRoleManager(env fallback roles), with only Discord mocked.FreeandProreturned 500 with the traceback from the issue. That file is nowtests/src/webhooks/test_subscription_change_webhook.pyand asserts the new behaviour. Not verified against the production database or a real guild.🤖 Generated with Claude Code