{"record":{"id":"ff3f588b6f633368","repo":"OtterMind/Chat2DB","slug":"largecellvalue-rownotfound","errorCode":"largeCellValue.rowNotFound","errorMessage":"largeCellValue.rowNotFound","messagePattern":"largeCellValue\\.rowNotFound","errorType":"error_code","errorClass":"BusinessException","httpStatus":null,"severity":"warning","filePath":"chat2db-community-server/chat2db-community-domain/chat2db-community-domain-core/src/main/java/ai/chat2db/community/domain/core/impl/db/DbCellValueServiceImpl.java","lineNumber":64,"sourceCode":"    private static final int BINARY_TYPE_SAMPLE_SIZE = 64 * 1024;\n    private static final String TEXT_PLAIN = \"text/plain\";\n    private static final String TEXT_DOWNLOAD = \"text/plain;charset=UTF-8\";\n    private static final String APPLICATION_JSON = \"application/json\";\n    private static final String IMAGE_WILDCARD = \"image/*\";\n\n    @Override\n    public CellValueChunk readChunk(DbCellValueChunkReadRequest readCellValueChunkRequest) {\n        LargeValueReference reference = readCellValueChunkRequest == null ? null : readCellValueChunkRequest.getReference();\n        Long offsetParam = readCellValueChunkRequest == null ? null : readCellValueChunkRequest.getOffset();\n        Integer limitParam = readCellValueChunkRequest == null ? null : readCellValueChunkRequest.getLimit();\n        CellValueFormatEnum format = CellValueFormatEnum.fromRequest(\n                readCellValueChunkRequest == null ? null : readCellValueChunkRequest.getFormat());\n        long offset = Math.max(0L, offsetParam == null ? 0L : offsetParam);\n        int limit = normalizeLimit(limitParam, format);\n        try (PreparedStatement statement = prepareStatement(reference);\n             ResultSet resultSet = statement.executeQuery()) {\n            if (!resultSet.next()) {\n                throw new BusinessException(\"largeCellValue.rowNotFound\");\n            }\n            Object value = resultSet.getObject(1);\n            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            return valueType.isBinaryLike()\n                    ? readBinaryChunk(resultSet, value, offset, limit, format, reference, valueType)\n                    : readTextChunk(resultSet, value, offset, limit, format, reference, valueType);\n        } catch (SQLException | IOException e) {\n            throw new BusinessException(\"largeCellValue.readFailed\", new Object[]{e.getMessage()}, e);\n        }\n    }\n\n    @Override\n    public CellValueDownload prepareDownload(LargeValueReference reference, String format) {\n        try (PreparedStatement statement = prepareStatement(reference);","sourceCodeStart":46,"sourceCodeEnd":82,"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#L46-L82","documentation":"Thrown while reading a chunk of a large cell value when the prepared SELECT against the source table returns no rows (resultSet.next() is false). The LargeValueReference points at a row identified by primary key, and that row no longer exists in the database at read time.","triggerScenarios":"readChunk() is called with a stale LargeValueReference whose primary key was deleted, the row was modified so the key no longer matches, or the underlying table/data changed between result-set generation and the chunk fetch. Concurrent deletes or a transaction visibility mismatch can also produce an empty result.","commonSituations":"User opens a large cell, leaves it open, then the row is deleted by another session or by a re-run of a query whose result set is now stale; reference carries a primary key that the dialect cannot round-trip.","solutions":["Instruct the user to refresh the result set and reopen the cell to obtain a fresh LargeValueReference.","Verify the reference's primary key column(s) are populated and correct before issuing readChunk.","If rows are volatile, shorten the window between generating the reference and reading chunks, or snapshot the row."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Best-effort pre-check that the source row still exists\ntry (PreparedStatement ps = conn.prepareStatement(\n        \"SELECT 1 FROM \" + table + \" WHERE \" + pkPredicate)) {\n    bindPk(ps, reference.getPrimaryKey());\n    try (ResultSet rs = ps.executeQuery()) {\n        if (!rs.next()) {\n            // tell the user to refresh the result set instead of calling readChunk\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    cellValueService.readChunk(request);\n} catch (BusinessException e) {\n    if (\"largeCellValue.rowNotFound\".equals(e.getCode())) {\n        // surface 'row no longer exists; refresh the result set' to the user\n    } else {\n        throw e;\n    }\n}","preventionTips":["Invalidate cell references when the parent result set is refreshed or closed.","Keep the window between opening a cell and reading chunks short for volatile tables.","Disable the read UI once the result set is known to be stale."],"tags":["cell-value","large-value","stale-reference","concurrency"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}