@@ -346,6 +346,7 @@ def handle_key_type(data: GenerateKeyRequest, data_json: dict) -> dict:
346
346
data_json ["allowed_routes" ] = ["info_routes" ]
347
347
return data_json
348
348
349
+
349
350
async def validate_team_id_used_in_service_account_request (
350
351
team_id : Optional [str ],
351
352
prisma_client : Optional [PrismaClient ],
@@ -358,13 +359,13 @@ async def validate_team_id_used_in_service_account_request(
358
359
status_code = 400 ,
359
360
detail = "team_id is required for service account keys. Please specify `team_id` in the request body." ,
360
361
)
361
-
362
+
362
363
if prisma_client is None :
363
364
raise HTTPException (
364
365
status_code = 400 ,
365
366
detail = "prisma_client is required for service account keys. Please specify `prisma_client` in the request body." ,
366
367
)
367
-
368
+
368
369
# check if team_id exists in the database
369
370
team = await prisma_client .db .litellm_teamtable .find_unique (
370
371
where = {"team_id" : team_id },
@@ -376,6 +377,7 @@ async def validate_team_id_used_in_service_account_request(
376
377
)
377
378
return True
378
379
380
+
379
381
async def _common_key_generation_helper ( # noqa: PLR0915
380
382
data : GenerateKeyRequest ,
381
383
user_api_key_dict : UserAPIKeyAuth ,
@@ -557,7 +559,7 @@ async def _common_key_generation_helper( # noqa: PLR0915
557
559
status_code = 400 ,
558
560
detail = {
559
561
"error" : f"Invalid key format. LiteLLM Virtual Key must start with 'sk-'. Received: { data .key } "
560
- }
562
+ },
561
563
)
562
564
563
565
response = await generate_key_helper_fn (
@@ -2885,7 +2887,10 @@ async def unblock_key(
2885
2887
param = "key" ,
2886
2888
code = status .HTTP_400_BAD_REQUEST ,
2887
2889
)
2888
- hashed_token = hash_token (token = data .key )
2890
+ if data .key .startswith ("sk-" ):
2891
+ hashed_token = hash_token (token = data .key )
2892
+ else :
2893
+ hashed_token = data .key
2889
2894
2890
2895
if litellm .store_audit_logs is True :
2891
2896
# make an audit log for key update
0 commit comments