{"record":{"id":"7942a575848eba97","repo":"alibaba/spring-ai-alibaba","slug":"failed-to-parse-store-key-storekey","errorCode":null,"errorMessage":"Failed to parse store key: {storeKey}","messagePattern":"Failed to parse store key: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/store/stores/BaseStore.java","lineNumber":148,"sourceCode":"\t\t}\n\t}\n\n\t/**\n\t * Parse store key to namespace and key.\n\t * @param storeKey store key\n\t * @return array containing [namespace, key]\n\t */\n\t@SuppressWarnings(\"unchecked\")\n\tprotected Object[] parseStoreKey(String storeKey) {\n\t\ttry {\n\t\t\tbyte[] decoded = Base64.getDecoder().decode(storeKey);\n\t\t\tMap<String, Object> keyData = new ObjectMapper().readValue(decoded, Map.class);\n\t\t\tList<String> namespace = (List<String>) keyData.get(\"namespace\");\n\t\t\tString key = (String) keyData.get(\"key\");\n\t\t\treturn new Object[] { namespace, key };\n\t\t}\n\t\tcatch (Exception e) {\n\t\t\tthrow new RuntimeException(\"Failed to parse store key: \" + storeKey, e);\n\t\t}\n\t}\n\n\t/**\n\t * Check if namespace starts with given prefix.\n\t * @param namespace namespace to check\n\t * @param prefix prefix to match\n\t * @return true if starts with prefix\n\t */\n\tprotected boolean startsWithPrefix(List<String> namespace, List<String> prefix) {\n\t\tif (prefix.isEmpty()) {\n\t\t\treturn true;\n\t\t}\n\t\tif (prefix.size() > namespace.size()) {\n\t\t\treturn false;\n\t\t}\n\t\tfor (int i = 0; i < prefix.size(); i++) {\n\t\t\tif (!Objects.equals(namespace.get(i), prefix.get(i))) {","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/alibaba/spring-ai-alibaba/blob/f82da0b50f35744c13968191be2b1cd2452ef550/spring-ai-alibaba-graph-core/src/main/java/com/alibaba/cloud/ai/graph/store/stores/BaseStore.java#L130-L166","documentation":"parseStoreKey decodes a Base64 store key back into {namespace, key}; if decoding or JSON parsing fails it throws RuntimeException(\"Failed to parse store key: <key>\"). A malformed, corrupted, or non-library-generated storeKey cannot be round-tripped, so the operation aborts with the offending key in the message.","triggerScenarios":"Passing a storeKey that was truncated, hand-edited, generated by a different key scheme/version, or not valid Base64/JSON into APIs that accept a storeKey (e.g. reading by stored key reference).","commonSituations":"Migrating data between store implementations with different key formats; copying keys from logs with clipping/whitespace; upgrading the library after the key encoding changed; manually constructing keys.","solutions":["Verify the storeKey is intact, valid Base64, and was produced by createStoreKey (decode it manually to check).","Re-derive the key from namespace+key with createStoreKey instead of reusing cached/hand-copied values.","Catch RuntimeException around parseStoreKey and treat invalid keys as not-found; log the full key for diagnosis.","If keys came from an older library version, migrate/re-encode stored keys with the current createStoreKey."],"exampleFix":"// before\nObject[] nsKey = store.parseStoreKey(storedKey);\n// after\ntry {\n    Object[] nsKey = store.parseStoreKey(storedKey.trim());\n} catch (RuntimeException e) {\n    log.warn(\"Corrupt store key, rebuilding\", e);\n    String rebuilt = store.createStoreKey(expectedNamespace, expectedKey);\n    Object[] nsKey = store.parseStoreKey(rebuilt);\n}","handlingStrategy":"try-catch","validationCode":"boolean looksLikeStoreKey(String k) {\n    if (k == null || k.isBlank()) return false;\n    try { java.util.Base64.getDecoder().decode(k); return true; }\n    catch (IllegalArgumentException e) { return false; }\n}","typeGuard":"boolean isValidStoreKey(String k) {\n    if (k == null || k.isBlank()) return false;\n    try { java.util.Base64.getDecoder().decode(k); return true; }\n    catch (IllegalArgumentException e) { return false; }\n}","tryCatchPattern":"try {\n    Object[] nsKey = store.parseStoreKey(storeKey.trim());\n} catch (RuntimeException e) {\n    log.warn(\"Unparseable store key: {}\", e.getMessage());\n    throw new ResourceNotFoundException(\"store key invalid\");\n}","preventionTips":["Never hand-edit or truncate store keys copied from logs.","Always regenerate keys via createStoreKey from namespace+key.","During library upgrades, migrate stored keys rather than reusing old encodings."],"tags":["java","base64","parsing","store"],"backgroundTag":"invalid-argument-format","analyzedSha":"f82da0b50f35744c13968191be2b1cd2452ef550","analyzedAt":"2026-09-09T15:32:42.421Z","contentChangedAt":"2026-09-09T15:32:42.421Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}