Repository navigation
Commit c1bbd75
authored
fix(service-accounts): Don't look up a member limit with no user (#129906)
`is_member_disabled_from_limit` now returns False for a caller with no
user, before any membership lookup. Seat limits apply to members, and a
service account isn't one.
The function takes an `HttpRequest`, so the `request.user` mypy check
didn't cover its `user.id` read. Sentry's own permission classes pass an
`RpcUserOrganizationContext` and never reach that read. getsentry's
customer details endpoint passes a DRF request with an `Organization`,
which goes to `check_membership_by_id(user_id=user.id)`. A service
account with `org:billing` gets 403 `user-required` there today, from
the `ServiceAccountId` guard. Once #129763 removes the guard, it gets a
500. Passing `acting_user_id` instead would send `None` into a lookup
that matches pending invites, so the function returns early.
The new test on master:
```
E sentry.api.exceptions.UserRequired: {'detail': {'code': 'user-required', 'message': 'This action requires a user.', 'extra': {}}}
FAILED tests/sentry/api/test_utils.py::IsMemberDisabledFromLimitTest::test_service_account_is_not_a_limited_member
```
With the fix, the API utils, organization permission and permissions
suites pass (214 tests).1 parent 0ed1f4f commit c1bbd75
2 files changed
Lines changed: 18 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
26 | 27 | | |
27 | 28 | | |
28 | 29 | | |
| |||
307 | 308 | | |
308 | 309 | | |
309 | 310 | | |
310 | | - | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
311 | 314 | | |
312 | 315 | | |
313 | 316 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
| 20 | + | |
19 | 21 | | |
20 | 22 | | |
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| 27 | + | |
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
| |||
336 | 339 | | |
337 | 340 | | |
338 | 341 | | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
339 | 353 | | |
340 | 354 | | |
341 | 355 | | |
| |||
0 commit comments