mirror of
https://github.com/Routstr/routstr-core.git
synced 2026-10-05 20:28:23 +00:00
fix: keep the Key not found prefix so routstr SDK purges dead keys
This commit is contained in:
@@ -232,7 +232,7 @@ separately as `key_not_found` (also 401) — see
|
||||
{
|
||||
"error": {
|
||||
"type": "invalid_request_error",
|
||||
"message": "API key not found. Deposit first via /v1/wallet/create to get a key on this node.",
|
||||
"message": "Key not found. Deposit first via /v1/wallet/create to get a key on this node.",
|
||||
"code": "key_not_found"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -129,7 +129,7 @@ by key pruning. This is *not* a formatting problem.
|
||||
{
|
||||
"error": {
|
||||
"type": "invalid_request_error",
|
||||
"message": "API key not found. Deposit first via /v1/wallet/create to get a key on this node.",
|
||||
"message": "Key not found. Deposit first via /v1/wallet/create to get a key on this node.",
|
||||
"code": "key_not_found"
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -298,11 +298,16 @@ async def _validate_bearer_key_locked(
|
||||
# Falling through to the generic handler below would report it as
|
||||
# "Invalid API key format", sending callers after a formatting bug
|
||||
# that does not exist. Report the real cause instead.
|
||||
#
|
||||
# Keep the "Key not found." prefix verbatim: @routstr/sdk (<=0.4.6)
|
||||
# detects a dead key with a case-sensitive `body.includes("Key not
|
||||
# found")` probe, and uses it to purge the key from its store. The
|
||||
# refund path in balance.py already relies on the same prefix.
|
||||
raise HTTPException(
|
||||
status_code=401,
|
||||
detail={
|
||||
"error": {
|
||||
"message": "API key not found. Deposit first via /v1/wallet/create to get a key on this node.",
|
||||
"message": "Key not found. Deposit first via /v1/wallet/create to get a key on this node.",
|
||||
"type": "invalid_request_error",
|
||||
"code": "key_not_found",
|
||||
}
|
||||
|
||||
@@ -350,6 +350,10 @@ async def test_unknown_sk_key_reports_key_not_found(session: AsyncSession) -> No
|
||||
assert detail["error"]["type"] == "invalid_request_error"
|
||||
assert detail["error"]["code"] == "key_not_found"
|
||||
assert "format" not in detail["error"]["message"].lower()
|
||||
# @routstr/sdk (<=0.4.6) purges a dead key on a case-sensitive
|
||||
# `body.includes("Key not found")` probe, so the prefix is part of the
|
||||
# wire contract, not cosmetic.
|
||||
assert detail["error"]["message"].startswith("Key not found.")
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
|
||||
Reference in New Issue
Block a user