{"record":{"id":"3ba7499f0bbc2b7c","repo":"prestodb/presto","slug":"unable-to-restore-snapshot-snapshotjson","errorCode":null,"errorMessage":"Unable to restore snapshot \"${snapshotJson}\".","messagePattern":"Unable to restore snapshot \"(.+?)\"\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"presto-verifier/src/main/java/com/facebook/presto/verifier/framework/DdlVerification.java","lineNumber":116,"sourceCode":"                    snapshotQueryConsumer.accept(new SnapshotQuery(getSourceQuery().getSuite(), getSourceQuery().getName(), isExplain, snapshot));\n                    return new DdlMatchResult(MATCH, Optional.empty(), \"\", \"\");\n                }\n                catch (JsonProcessingException exception) {\n                    throw new RuntimeException(\"Unable to save snapshot \\\"\" + controlChecksum + \"\\\".\");\n                }\n            }\n        }\n        else if (QUERY_BANK_MODE.equals(runningMode)) {\n            String key = format(VERIFIER_SNAPSHOT_KEY_PATTERN, getSourceQuery().getSuite(), getSourceQuery().getName(), isExplain);\n            SnapshotQuery snapshotQuery = snapshotQueries.get(key);\n            if (snapshotQuery != null) {\n                ObjectMapper objectMapper = new ObjectMapper();\n                String snapshotJson = snapshotQuery.getSnapshot();\n                try {\n                    controlChecksum = objectMapper.readValue(snapshotJson, String.class);\n                }\n                catch (JsonProcessingException exception) {\n                    throw new RuntimeException(\"Unable to restore snapshot \\\"\" + snapshotJson + \"\\\".\");\n                }\n            }\n            else {\n                return new DdlMatchResult(SNAPSHOT_DOES_NOT_EXIST, Optional.empty(), \"\", \"\");\n            }\n        }\n\n        Statement testChecksumQuery = getChecksumQuery(test);\n        testChecksumQueryContext.setChecksumQuery(formatSql(testChecksumQuery));\n        String testChecksum = getOnlyElement(callAndConsume(\n                () -> getHelperAction().execute(testChecksumQuery, TEST_CHECKSUM, checksumConverter),\n                stats -> stats.getQueryStats().map(QueryStats::getQueryId).ifPresent(testChecksumQueryContext::setChecksumQueryId)).getResults());\n\n        S controlObject;\n        S testObject;\n\n        try {\n            controlObject = (S) sqlParser.createStatement(controlChecksum, PARSING_OPTIONS);","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-verifier/src/main/java/com/facebook/presto/verifier/framework/DdlVerification.java#L98-L134","documentation":"DdlVerification, in snapshot mode, reads a previously stored snapshot JSON string and deserializes it back into the control checksum via objectMapper.readValue(snapshotJson, String.class). If the stored snapshot is not valid JSON (or not a JSON string), it throws this RuntimeException, causing the DDL verification to fail rather than proceed with a corrupt checksum.","triggerScenarios":"Running verify in QUERY_BANK_SNAPSHOT_MODE where snapshotQueries contains an entry whose snapshot string was truncated, manually edited, double-escaped, or written by a different/incompatible verifier version.","commonSituations":"Snapshot store (e.g. MySQL query_bank table) edited manually; snapshot saved by a newer verifier with a different serialization; database column truncation cutting the JSON mid-string; copying snapshots between environments with different encodings.","solutions":["Inspect the snapshot JSON named in the message; validate it is a proper JSON string literal.","Delete/re-save the corrupted snapshot entry in the query bank store and re-run the verification in setup mode to regenerate it.","Use the same verifier version for snapshot setup and verification runs.","Check the store column width/charset so the JSON is not truncated on save."],"exampleFix":"// before\nthrow new RuntimeException(\"Unable to restore snapshot \\\"\" + snapshotJson + \"\\\".\");\n// after\nthrow new RuntimeException(\"Unable to restore snapshot \\\"\" + snapshotJson + \"\\\".\", exception);","handlingStrategy":"validation","validationCode":"// Java: validate snapshot JSON before deserializing\nif (snapshotJson == null || !snapshotJson.startsWith(\"\\\"\") || !snapshotJson.endsWith(\"\\\"\")) {\n    throw new IllegalArgumentException(\"Corrupt snapshot, expected JSON string: \" + snapshotJson);\n}","typeGuard":null,"tryCatchPattern":"try {\n    controlChecksum = objectMapper.readValue(snapshotJson, String.class);\n} catch (JsonProcessingException exception) {\n    throw new RuntimeException(\"Unable to restore snapshot \\\"\" + snapshotJson + \"\\\".\", exception);\n}","preventionTips":["Regenerate corrupted snapshots by re-running the verifier in setup mode.","Use the same verifier version for snapshot setup and verification.","Ensure snapshot store columns are large enough and UTF-8 encoded.","Do not manually edit snapshot JSON in the query bank."],"tags":["verifier","json","jackson","snapshot"],"backgroundTag":"json-deserialization-failed","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}