Skip to content

Commit c3fdc55

Browse files
jopemachineclaude
andcommitted
fix(BA-7364): require the rate limit field on the auth response
A missing field defaulting to null reads as unlimited, so an incomplete payload would silently disable the limit. Null stays a valid value — it is what an unset limit means — but it now has to be sent explicitly. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent b6f8820 commit c3fdc55

4 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/ai/backend/common/dto/manager/auth/types.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class AuthSuccessResponse(AuthResponse):
5858
status: str
5959
session_token: str
6060
user_id: UserID
61-
rate_limit: int | None = None
61+
rate_limit: int | None
6262
type: AuthTokenType = AuthTokenType.KEYPAIR
6363

6464
def to_dict(self) -> dict[str, Any]:

tests/unit/client_v2/test_auth_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ async def test_authorize(self, sample_client_type_id: UUID) -> None:
8282
"status": "active",
8383
"session_token": "test_session_token",
8484
"user_id": "12345678-1234-5678-1234-567812345678",
85+
"rate_limit": None,
8586
"type": AuthTokenType.KEYPAIR,
8687
},
8788
}

tests/unit/common/dto/manager/auth/test_auth_response.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def test_authorize_response() -> None:
3434
status="active",
3535
session_token="test_session_token",
3636
user_id=UserID(uuid4()),
37+
rate_limit=None,
3738
type=AuthTokenType.KEYPAIR,
3839
)
3940
resp = AuthorizeResponse(data=data)

tests/unit/common/dto/manager/auth/test_auth_types.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ def test_auth_success_response_creation() -> None:
4545
status="active",
4646
session_token="test_session_token",
4747
user_id=UserID(uuid4()),
48+
rate_limit=None,
4849
)
4950
assert resp.access_key == "AKTEST"
5051
assert resp.secret_key == "SKTEST"
@@ -62,6 +63,7 @@ def test_auth_success_response_to_dict() -> None:
6263
status="active",
6364
session_token="test_session_token",
6465
user_id=UserID(uuid4()),
66+
rate_limit=None,
6567
type=AuthTokenType.JWT,
6668
)
6769
d = resp.to_dict()
@@ -123,6 +125,7 @@ def test_parse_auth_response_success() -> None:
123125
"status": "active",
124126
"session_token": "test_token",
125127
"user_id": "12345678-1234-5678-1234-567812345678",
128+
"rate_limit": None,
126129
}
127130
result = parse_auth_response(data)
128131
assert isinstance(result, AuthSuccessResponse)
@@ -159,6 +162,7 @@ def test_parse_auth_response_explicit_success() -> None:
159162
"status": "active",
160163
"session_token": "test_token",
161164
"user_id": "12345678-1234-5678-1234-567812345678",
165+
"rate_limit": None,
162166
}
163167
result = parse_auth_response(data)
164168
assert isinstance(result, AuthSuccessResponse)

0 commit comments

Comments
 (0)