{"record":{"id":"1d1bfe3daedf8196","repo":"OtterMind/Chat2DB","slug":"sqlite-index-must-contain-at-least-one-named-colum","errorCode":null,"errorMessage":"SQLite index must contain at least one named column","messagePattern":"SQLite index must contain at least one named column","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"chat2db-community-server/chat2db-community-plugins/chat2db-community-sqlite/src/main/java/ai/chat2db/plugin/sqlite/enums/type/SqliteIndexTypeEnum.java","lineNumber":109,"sourceCode":"    private String buildIndexComment(TableIndex tableIndex) {\n        if (StringUtils.isBlank(tableIndex.getComment())) {\n            return \"\";\n        } else {\n            return StringUtils.join(SQL_COMMENT, tableIndex.getComment(), \"'\");\n        }\n\n    }\n\n    private String buildIndexColumn(TableIndex tableIndex) {\n        StringBuilder script = new StringBuilder();\n        script.append(\"(\");\n        for (TableIndexColumn column : tableIndex.getColumnList()) {\n            if (StringUtils.isNotBlank(column.getColumnName())) {\n                script.append(quoteName(column.getColumnName())).append(\",\");\n            }\n        }\n        if (script.length() == 1) {\n            throw new IllegalArgumentException(\"SQLite index must contain at least one named column\");\n        }\n        script.deleteCharAt(script.length() - 1);\n        script.append(\")\");\n        return script.toString();\n    }\n\n    private String buildIndexName(TableIndex tableIndex) {\n        if (this.equals(PRIMARY_KEY)) {\n            return quoteName(tableIndex.getTableName() + \"_pk\");\n        } else {\n            return quoteName(tableIndex.getName());\n        }\n    }\n\n    private static String quoteName(String name) {\n        return SqliteIdentifierProcessor.INSTANCE.quoteIdentifierAlways(name);\n    }\n","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/OtterMind/Chat2DB/blob/5ee1e990e73fbcae1969dc554be254fedb3ab888/chat2db-community-server/chat2db-community-plugins/chat2db-community-sqlite/src/main/java/ai/chat2db/plugin/sqlite/enums/type/SqliteIndexTypeEnum.java#L91-L127","documentation":"Thrown by SqliteIndexTypeEnum.buildIndexColumn when, after iterating tableIndex.getColumnList(), no entry had a non-blank columnName. The method builds the parenthesized column list by appending quoted names; if nothing was appended the buffer is still just '(', so it fails rather than emit malformed DDL.","triggerScenarios":"Building an index whose columnList is empty, or whose every column has a null/blank getColumnName().","commonSituations":"An index created in the UI before columns are chosen; metadata that lists an index without resolved column names; partial-column model serialization.","solutions":["Populate columnList with at least one TableIndexColumn carrying a non-blank columnName.","Reject/validate empty index columns at the API boundary before DDL generation.","Skip the index entirely when no columns are configured."],"exampleFix":"// before\nindex.setColumnList(Collections.emptyList());\n// -> SQLite index must contain at least one named column\n\n// after\nTableIndexColumn c = new TableIndexColumn();\nc.setColumnName(\"rowid\");\nindex.setColumnList(List.of(c));","handlingStrategy":"validation","validationCode":"boolean hasNamed = tableIndex.getColumnList() != null\n    && tableIndex.getColumnList().stream()\n        .anyMatch(c -> StringUtils.isNotBlank(c.getColumnName()));\nif (!hasNamed) {\n    throw new IllegalArgumentException(\"SQLite index needs a named column\");\n}","typeGuard":"static boolean sqliteIndexHasNamedColumn(TableIndex idx) {\n    return idx.getColumnList() != null && idx.getColumnList().stream()\n        .anyMatch(c -> StringUtils.isNotBlank(c.getColumnName()));\n}","tryCatchPattern":null,"preventionTips":["Reject indexes with no columns at the API boundary.","Skip DDL for empty indexes.","Ensure metadata resolves index column names."],"tags":["sqlite","ddl","index","validation"],"backgroundTag":null,"analyzedSha":"5ee1e990e73fbcae1969dc554be254fedb3ab888","analyzedAt":"2026-08-14T07:05:03.077Z","schemaVersion":2},"datasetVersion":"2026-08-14T10:17:34.591Z"}