{"record":{"id":"037d55769fe7c57d","repo":"apache/cassandra","slug":"unknown-cli-layout","errorCode":null,"errorMessage":"Unknown CLI layout: ","messagePattern":"Unknown CLI layout: ","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/tools/NodeTool.java","lineNumber":220,"sourceCode":"    private static void configureCliLayout(CommandLine commandLine)\n    {\n        CliLayout defaultLayout = CliLayout.valueOf(toUpperCaseLocalized(CassandraRelevantProperties.CASSANDRA_CLI_LAYOUT.getDefaultValue()));\n        CliLayout layoutEnv = CassandraRelevantEnv.CASSANDRA_CLI_LAYOUT.getEnum(true, CliLayout.class,\n                                                                                CassandraRelevantProperties.CASSANDRA_CLI_LAYOUT.getDefaultValue());\n        CliLayout layoutSys = CassandraRelevantProperties.CASSANDRA_CLI_LAYOUT.getEnum(true, CliLayout.class);\n        CliLayout layout = layoutEnv != defaultLayout ? layoutEnv : layoutSys;\n\n        switch (layout)\n        {\n            case AIRLINE:\n                commandLine.setHelpFactory(CassandraCliHelpLayout::new)\n                           .setUsageHelpWidth(CassandraCliHelpLayout.DEFAULT_USAGE_HELP_WIDTH)\n                           .setHelpSectionKeys(CassandraCliHelpLayout.cassandraHelpSectionKeys());\n                break;\n            case PICOCLI:\n                break;\n            default:\n                throw new IllegalStateException(\"Unknown CLI layout: \" + layout);\n        }\n    }\n\n    protected void badUse(Exception e)\n    {\n        output.out.println(\"nodetool: \" + e.getMessage());\n        output.out.println(\"See 'nodetool help' or 'nodetool help <command>'.\");\n    }\n\n    protected void err(Throwable e)\n    {\n        // CASSANDRA-11537: friendly error message when server is not ready\n        if (e instanceof InstanceNotFoundException)\n            throw new IllegalArgumentException(\"Server is not initialized yet, cannot run nodetool.\");\n\n        output.err.println(\"error: \" + e.getMessage());\n        output.err.println(\"-- StackTrace --\");\n        output.err.println(getStackTraceAsString(e));","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/tools/NodeTool.java#L202-L238","documentation":"NodeTool.configureCliLayout switches on a CliLayout enum to set up help/usage formatting. The default branch throws an IllegalStateException('Unknown CLI layout: ' + layout) — meaning the configured layout value is not one of the supported variants (e.g. the DEFAULT/CASSANDRA and PICOCLI layouts). Since enums normally prevent this, it usually arises from a new enum constant added without a corresponding case, or a deserialized/foreign enum value.","triggerScenarios":"Launching NodeTool when ToolCommand default layout is set to an enum value not handled in the switch — typically a newly added CliLayout constant in a custom/patched build, or code compiled against a different enum version than the running NodeTool class.","commonSituations":"Custom Cassandra forks adding new CLI layouts without updating configureCliLayout; hot-swapping jars of mixed versions; developers adding an enum constant in a patch without extending the switch.","solutions":["Add a case (or intentionally rely on the default behavior) for the missing CliLayout constant in configureCliLayout.","Verify the CliLayout enum and NodeTool classes come from the same build/version.","Rebuild the project cleanly so enum and switch definitions are consistent.","If this is a stock build, report the mismatch and fall back to the default layout configuration."],"exampleFix":"// before\nswitch (layout) {\n    case DEFAULT_CASSANDRA: ... break;\n    case PICOCLI: break;\n    default: throw new IllegalStateException(\"Unknown CLI layout: \" + layout);\n}\n// after\nswitch (layout) {\n    case DEFAULT_CASSANDRA: ... break;\n    case PICOCLI: break;\n    case NEW_LAYOUT: configureNewLayout(); break;\n    default: throw new IllegalStateException(\"Unknown CLI layout: \" + layout);\n}","handlingStrategy":"validation","validationCode":"// guard before use\nObjects.requireNonNull(layout, \"CLI layout must be set\");\nif (layout != CliLayout.DEFAULT_CASSANDRA && layout != CliLayout.PICOCLI)\n    throw new IllegalStateException(\"Unsupported CliLayout: \" + layout);","typeGuard":null,"tryCatchPattern":"try { nodeTool.execute(args); }\ncatch (IllegalStateException e) { if (e.getMessage().startsWith(\"Unknown CLI layout\")) log.error(\"Unsupported layout configured: {}\", layout); }","preventionTips":["When adding a CliLayout constant, always extend configureCliLayout's switch","Keep enum and NodeTool classes in the same build","Prefer exhaustive switch expressions over switch statements to get compiler checks"],"tags":["cli","enum","state","nodetool"],"backgroundTag":"invalid-enum-value","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}