From 3ef6ccee7fa6e59bb17e6432fda19d503406499a Mon Sep 17 00:00:00 2001 From: Accusys Date: Mon, 5 Oct 2026 03:01:42 +0800 Subject: [PATCH] fix: key_type stored as bare string instead of JSON string **Problem**: - key_type stored as "user" (with quotes, len=6) - Future WHERE key_type = 'user' would silently fail **Solution**: - Added ApiKeyType::as_str() method - Returns bare string: "system", "user", etc. - handlers.rs:437 now uses as_str() instead of serde_json::to_string() **Impact**: - Existing test keys in test DBs can be safely ignored - Production DB has no api_keys yet - No code relies on JSON-quoted format --- src/core/api_key/models.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/core/api_key/models.rs b/src/core/api_key/models.rs index 7b671bda..46c3c4e0 100644 --- a/src/core/api_key/models.rs +++ b/src/core/api_key/models.rs @@ -16,6 +16,16 @@ pub enum ApiKeyType { } impl ApiKeyType { + pub fn as_str(&self) -> &'static str { + match self { + ApiKeyType::System => "system", + ApiKeyType::User => "user", + ApiKeyType::Service => "service", + ApiKeyType::Integration => "integration", + ApiKeyType::Emergency => "emergency", + } + } + pub fn prefix(&self) -> &'static str { match self { ApiKeyType::System => "msys_",