Skip to content

Conversation

mdtro
Copy link
Contributor

@mdtro mdtro commented Mar 13, 2024

To prevent abuse of the email invite functionality, require users who want to issue invites to have already verified their emails first.

@mdtro mdtro changed the title require verified email to send invites fix: require verified email to send invites Mar 13, 2024
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 13, 2024
@mdtro mdtro marked this pull request as draft March 13, 2024 11:05
Copy link

codecov bot commented Mar 13, 2024

❌ 13 Tests Failed:

Tests completed Failed Passed Skipped
111 13 98 2
View the top 3 failed test(s) by shortest run time
::tests.sentry.api.endpoints.test_system_options
Stack Traces | 0s run time
#x1B[31mImportError while importing test module '.../api/endpoints/test_system_options.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1........./x64/lib/python3.13/importlib/__init__.py#x1B[0m:88: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
#x1B[1m#x1B[.../api/endpoints/test_system_options.py#x1B[0m:9: in <module>
    class SystemOptionsTest(APITestCase):
#x1B[1m#x1B[.../api/endpoints/test_system_options.py#x1B[0m:10: in SystemOptionsTest
    url = reverse("sentry-api-0-system-options")
#x1B[1m#x1B[31m.venv/lib/python3.13.../django/urls/base.py#x1B[0m:88: in reverse
    return resolver._reverse_with_prefix(view, prefix, *args, **kwargs)
#x1B[1m#x1B[31m.venv/lib/python3.13.../django/urls/resolvers.py#x1B[0m:749: in _reverse_with_prefix
    self._populate()
#x1B[1m#x1B[31m.venv/lib/python3.13.../django/urls/resolvers.py#x1B[0m:548: in _populate
    for url_pattern in reversed(self.url_patterns):
#x1B[1m#x1B[31m.venv/lib/python3.13.../django/utils/functional.py#x1B[0m:47: in __get__
    res = instance.__dict__[self.name] = self.func(instance)
#x1B[1m#x1B[31m.venv/lib/python3.13.../django/urls/resolvers.py#x1B[0m:718: in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
#x1B[1m#x1B[31m.venv/lib/python3.13.../django/utils/functional.py#x1B[0m:47: in __get__
    res = instance.__dict__[self.name] = self.func(instance)
#x1B[1m#x1B[31m.venv/lib/python3.13.../django/urls/resolvers.py#x1B[0m:711: in urlconf_module
    return import_module(self.urlconf_name)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1........./x64/lib/python3.13/importlib/__init__.py#x1B[0m:88: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
#x1B[1m#x1B[.../sentry/conf/urls.py#x1B[0m:3: in <module>
    from sentry.web.urls import urlpatterns
#x1B[1m#x1B[.../sentry/web/urls.py#x1B[0m:168: in <module>
    include("sentry.api.urls"),
#x1B[1m#x1B[31m.venv/lib/python3.13.../django/urls/conf.py#x1B[0m:39: in include
    urlconf_module = import_module(urlconf_module)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1........./x64/lib/python3.13/importlib/__init__.py#x1B[0m:88: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
#x1B[1m#x1B[.../sentry/api/urls.py#x1B[0m:502: in <module>
    from .endpoints.organization_member import (
#x1B[1m#x1B[.../endpoints/organization_member/__init__.py#x1B[0m:132: in <module>
    from .requests.invite.index import OrganizationInviteRequestIndexEndpoint
#x1B[1m#x1B[.../requests/invite/index.py#x1B[0m:10: in <module>
    from sentry.api.decorators import email_verification_required
#x1B[1m#x1B[31mE   ImportError: cannot import name 'email_verification_required' from 'sentry.api.decorators' (.../sentry/api/decorators.py)#x1B[0m#x1B[0m
::tests.sentry.hybridcloud.apigateway.test_apigateway
Stack Traces | 0s run time
#x1B[31mImportError while importing test module '.../hybridcloud/apigateway/test_apigateway.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1.../x64/lib/python3.13/importlib/__init__.py#x1B[0m:88: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
#x1B[1m#x1B[.../hybridcloud/apigateway/test_apigateway.py#x1B[0m:11: in <module>
    from sentry.testutils.helpers.apigateway import ApiGatewayTestCase, verify_request_params
#x1B[1m#x1B[.../testutils/helpers/apigateway.py#x1B[0m:13: in <module>
    import sentry.api.urls as api_urls
#x1B[1m#x1B[.../sentry/api/urls.py#x1B[0m:502: in <module>
    from .endpoints.organization_member import (
#x1B[1m#x1B[.../endpoints/organization_member/__init__.py#x1B[0m:132: in <module>
    from .requests.invite.index import OrganizationInviteRequestIndexEndpoint
#x1B[1m#x1B[.../requests/invite/index.py#x1B[0m:10: in <module>
    from sentry.api.decorators import email_verification_required
#x1B[1m#x1B[31mE   ImportError: cannot import name 'email_verification_required' from 'sentry.api.decorators' (.../sentry/api/decorators.py)#x1B[0m#x1B[0m
::tests.sentry.middleware.integrations.parsers.test_github_enterprise
Stack Traces | 0s run time
#x1B[31mImportError while importing test module '.../integrations/parsers/test_github_enterprise.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1........./x64/lib/python3.13/importlib/__init__.py#x1B[0m:88: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
#x1B[1m#x1B[.../integrations/parsers/test_github_enterprise.py#x1B[0m:24: in <module>
    class GithubEnterpriseRequestParserTest(TestCase):
#x1B[1m#x1B[.../integrations/parsers/test_github_enterprise.py#x1B[0m:26: in GithubEnterpriseRequestParserTest
    path = reverse("sentry-integration-github-enterprise-webhook")
#x1B[1m#x1B[31m.venv/lib/python3.13.../django/urls/base.py#x1B[0m:88: in reverse
    return resolver._reverse_with_prefix(view, prefix, *args, **kwargs)
#x1B[1m#x1B[31m.venv/lib/python3.13.../django/urls/resolvers.py#x1B[0m:749: in _reverse_with_prefix
    self._populate()
#x1B[1m#x1B[31m.venv/lib/python3.13.../django/urls/resolvers.py#x1B[0m:548: in _populate
    for url_pattern in reversed(self.url_patterns):
#x1B[1m#x1B[31m.venv/lib/python3.13.../django/utils/functional.py#x1B[0m:47: in __get__
    res = instance.__dict__[self.name] = self.func(instance)
#x1B[1m#x1B[31m.venv/lib/python3.13.../django/urls/resolvers.py#x1B[0m:718: in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
#x1B[1m#x1B[31m.venv/lib/python3.13.../django/utils/functional.py#x1B[0m:47: in __get__
    res = instance.__dict__[self.name] = self.func(instance)
#x1B[1m#x1B[31m.venv/lib/python3.13.../django/urls/resolvers.py#x1B[0m:711: in urlconf_module
    return import_module(self.urlconf_name)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1........./x64/lib/python3.13/importlib/__init__.py#x1B[0m:88: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
#x1B[1m#x1B[.../sentry/conf/urls.py#x1B[0m:3: in <module>
    from sentry.web.urls import urlpatterns
#x1B[1m#x1B[.../sentry/web/urls.py#x1B[0m:168: in <module>
    include("sentry.api.urls"),
#x1B[1m#x1B[31m.venv/lib/python3.13.../django/urls/conf.py#x1B[0m:39: in include
    urlconf_module = import_module(urlconf_module)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1........./x64/lib/python3.13/importlib/__init__.py#x1B[0m:88: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
#x1B[1m#x1B[.../sentry/api/urls.py#x1B[0m:502: in <module>
    from .endpoints.organization_member import (
#x1B[1m#x1B[.../endpoints/organization_member/__init__.py#x1B[0m:132: in <module>
    from .requests.invite.index import OrganizationInviteRequestIndexEndpoint
#x1B[1m#x1B[.../requests/invite/index.py#x1B[0m:10: in <module>
    from sentry.api.decorators import email_verification_required
#x1B[1m#x1B[31mE   ImportError: cannot import name 'email_verification_required' from 'sentry.api.decorators' (.../sentry/api/decorators.py)#x1B[0m#x1B[0m

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

self.url, {"email": "eric@localhost", "role": "member", "teams": [self.team.slug]}
)

assert response.status_code == 401
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we also check the response if it's an actual email_verification_required error? Since checking for 401 is a really abstract

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yeah, I can check the error details. Good idea. :)

The frontend doesn't behave as expected, even though we return a 401. No error is actually rendered, so once I have the frontend changes in place, I'll come back to this PR.

@getsantry
Copy link
Contributor

getsantry bot commented Apr 4, 2024

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you add the label WIP, I will leave it alone unless WIP is removed ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@getsantry getsantry bot added the Stale label Apr 4, 2024
@mdtro mdtro added WIP and removed Stale labels Apr 4, 2024
@mdtro mdtro force-pushed the mdtro/require-verified-email-to-invite branch from 9212bca to 6b73d0a Compare February 7, 2025 17:15
@mdtro mdtro closed this Jul 25, 2025
@github-actions github-actions bot locked and limited conversation to collaborators Aug 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components WIP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants