{"record":{"id":"67cc6d78b2b2cc89","repo":"quarkusio/quarkus","slug":"the-schema-cannot-be-empty-you-configure-the-inde","errorCode":null,"errorMessage":"The schema cannot be empty, you configure the indexed fields","messagePattern":"The schema cannot be empty, you configure the indexed fields","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/search/CreateArgs.java","lineNumber":380,"sourceCode":"            list.add(\"NOFIELDS\");\n        }\n\n        if (noFreqs) {\n            list.add(\"NOFREQS\");\n        }\n\n        if (stopWords != null && stopWords.length > 0) {\n            list.add(\"STOPWORDS\");\n            list.add(Integer.toString(stopWords.length));\n            Collections.addAll(list, stopWords);\n        }\n\n        if (skipInitialScan) {\n            list.add(\"SKIPINITIALSCAN\");\n        }\n\n        if (schema.isEmpty()) {\n            throw new IllegalArgumentException(\"The schema cannot be empty, you configure the indexed fields\");\n        }\n        list.add(\"SCHEMA\");\n        for (IndexedField field : schema) {\n            list.addAll(field.toArgs());\n        }\n\n        return list;\n    }\n\n}\n","sourceCodeStart":362,"sourceCodeEnd":391,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/extensions/redis-client/runtime/src/main/java/io/quarkus/redis/datasource/search/CreateArgs.java#L362-L391","documentation":"A RediSearch FT.CREATE index must declare at least one indexed field in its SCHEMA clause. CreateArgs.toArgs() throws IllegalArgumentException when the schema list built via field()/fieldAs... methods is empty, preventing sending a command Redis would reject.","triggerScenarios":"Calling ft().create(index, args) with an empty or never-populated schema — e.g. new CreateArgs().onHash() with no field() calls, or a schema whose field collection ended up empty due to failed filtering/empty config.","commonSituations":"Forgetting to add field(...)/fieldAsText(...) calls before create(); dynamic schema built from config or reflection that filtered out all fields; passing a schema collection that was empty at runtime.","solutions":["Add at least one field to the CreateArgs schema, e.g. args.field(\"name\").asText()","Verify the source of dynamic schema fields is populated before calling create()","Log or assert schema size before building the index"],"exampleFix":"// before\nCreateArgs args = new CreateArgs().onHash();\nft.create(\"idx\", args); // throws\n// after\nCreateArgs args = new CreateArgs().onHash();\nargs.field(\"title\").asText().field(\"year\").asNumeric();\nft.create(\"idx\", args);","handlingStrategy":"validation","validationCode":"if (schemaFields.isEmpty()) throw new IllegalStateException(\"FT.CREATE requires at least one indexed field in the schema\");\nCreateArgs args = new CreateArgs().onHash();\nschemaFields.forEach(f -> args.field(f.getName()).asText());","typeGuard":null,"tryCatchPattern":"try {\n    ft.create(index, args);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"schema cannot be empty\")) {\n        throw new IllegalStateException(\"No indexed fields configured for index \" + index, e);\n    }\n    throw e;\n}","preventionTips":["Always chain at least one field(...) call before create()","Validate that dynamic/config-driven schema sources are non-empty","Assert on the schema list size before invoking create()"],"tags":["redis","redisearch","illegal-argument","schema-validation-failed","empty-schema"],"backgroundTag":"schema-validation-failed","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}