Skip to content

Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.

fix: decrypt raises 'Ciphertext too short' on plaintext files shorter than 4 bytes (#1163)

yc1112337295660cd8ad
diff --git a/openviking/crypto/encryptor.py b/openviking/crypto/encryptor.py
index ca6609ebb..cf99a78e3 100644
--- a/openviking/crypto/encryptor.py
+++ b/openviking/crypto/encryptor.py
@@ -108,14 +108,16 @@ class FileEncryptor:
Returns:
Decrypted plaintext content
"""
- # 1. Check magic number
- if len(ciphertext) < MAGIC_LENGTH:
- raise InvalidMagicError("Ciphertext too short")
-
+ # 1. Check magic number (check prefix first, before length)
+ # This ensures plaintext files (including empty/short ones) are
+ # returned as-is instead of raising "Ciphertext too short".
if not ciphertext.startswith(MAGIC):
# Unencrypted file, return directly
return ciphertext
+ if len(ciphertext) < MAGIC_LENGTH:
+ raise InvalidMagicError("Ciphertext too short")
+
try:
# 2. Parse Envelope
(
diff --git a/openviking/utils/summarizer.py b/openviking/utils/summarizer.py
index d67a4b545..41d2c4664 100644
--- a/openviking/utils/summarizer.py
+++ b/openviking/utils/summarizer.py
@@ -56,7 +56,7 @@ class Summarizer:
enqueued_count = 0
telemetry = get_current_telemetry()
- for uri, temp_uri in zip(resource_uris, temp_uris):
+ for uri, temp_uri in zip(resource_uris, temp_uris, strict=True):
# Determine context_type based on URI
context_type = get_context_type_for_uri(uri)