{"record":{"id":"fab5c2c9ae8515bd","repo":"OtterMind/Chat2DB","slug":"largecellvalue-downloadfailed","errorCode":"largeCellValue.downloadFailed","errorMessage":"largeCellValue.downloadFailed","messagePattern":"largeCellValue\\.downloadFailed","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"error","filePath":"chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/db/DbCellValueServiceImpl.java","lineNumber":106,"sourceCode":"            int sqlType = reference.getSqlType() == null ? resultSet.getMetaData().getColumnType(1) : reference.getSqlType();\n            String columnType = StringUtils.defaultIfBlank(reference.getColumnType(),\n                    resultSet.getMetaData().getColumnTypeName(1));\n            LargeValueTypeEnum valueType = LargeValueTypeEnum.resolveForRead(value, columnType, sqlType,\n                    reference.getValueType());\n            CellValueFormatEnum outputFormat = CellValueFormatEnum.fromRequest(format).forDownload();\n            BinaryContentTypeEnum binaryContentType = valueType.isBinaryLike()\n                    ? detectBinaryContentType(valueType, openBinaryStream(resultSet, value))\n                    : BinaryContentTypeEnum.UNKNOWN;\n            LargeValueTypeEnum displayMode = valueType.withDetectedBinaryContent(binaryContentType);\n            String fileName = fileName(reference, outputFormat, displayMode, binaryContentType);\n            byte[] payload = toDownloadBytes(resultSet, value, outputFormat, displayMode);\n            return CellValueDownload.builder()\n                    .inputStream(new ByteArrayInputStream(payload))\n                    .fileName(fileName)\n                    .contentType(downloadContentType(outputFormat, displayMode, binaryContentType))\n                    .build();\n        } catch (SQLException | IOException e) {\n            throw new BusinessException(\"largeCellValue.downloadFailed\", new Object[]{e.getMessage()}, e);\n        }\n    }\n\n    private int normalizeLimit(Integer limit, CellValueFormatEnum format) {\n        int resolved = limit == null || limit <= 0 ? DEFAULT_CHUNK_SIZE : limit;\n        resolved = Math.min(resolved, MAX_CHUNK_SIZE);\n        if (format.isBase64() && resolved < BASE64_BYTE_GROUP) {\n            return BASE64_BYTE_GROUP;\n        }\n        if (format.isBase64() && resolved > BASE64_BYTE_GROUP) {\n            return resolved - (resolved % BASE64_BYTE_GROUP);\n        }\n        return resolved;\n    }\n\n    private PreparedStatement prepareStatement(LargeValueReference reference) throws SQLException {\n        if (reference.getPrimaryKey() == null || reference.getPrimaryKey().isEmpty()) {\n            throw new BusinessException(\"largeCellValue.rowLocatorRequired\");","sourceCodeStart":88,"sourceCodeEnd":124,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/db/DbCellValueServiceImpl.java#L88-L124","documentation":"Wraps SQLException or IOException raised while building the download payload in prepareDownload() (type detection, binary-content sniffing, byte conversion). The original message is the first format arg and the cause is chained.","triggerScenarios":"During download assembly: openBinaryStream or detectBinaryContentType fails, toDownloadBytes throws on a conversion/streaming error, or the JDBC connection drops while materializing the bytes.","commonSituations":"Large LOB exceeds driver/stream limits, binary content-type sniffing reads a closed stream, connection reset while streaming a big payload, or an unsupported format conversion.","solutions":["Read the chained cause to identify the SQLException/IOException root.","For streaming/size failures, download a smaller chunk or increase driver LOB limits.","Retry after reconnecting if the cause is a dropped connection.","Regenerate the reference from a fresh result set."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    CellValueDownload dl = cellValueService.prepareDownload(reference, format);\n    // stream dl.getInputStream()\n} catch (BusinessException e) {\n    if (\"largeCellValue.downloadFailed\".equals(e.getCode())) {\n        // log e.getCause(); offer chunked download or reconnect+retry\n    } else {\n        throw e;\n    }\n}","preventionTips":["Inspect the chained cause for the underlying SQLException/IOException.","For very large LOBs, prefer chunked reads over a single download payload.","Reconnect and retry on transient stream failures."],"tags":["cell-value","large-value","download","jdbc","io"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}