{"record":{"id":"1c1399e4526c91af","repo":"testcontainers/testcontainers-java","slug":"result-getstderr","errorCode":null,"errorMessage":"${result.getStderr()}","messagePattern":"\\$\\{result\\.getStderr\\(\\)\\}","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"modules/yugabytedb/src/main/java/org/testcontainers/containers/delegate/YugabyteDBYCQLDelegate.java","lineNumber":60,"sourceCode":"            .findFirst()\n            .get()\n            .getValue()\n            .getIpAddress();\n        try {\n            ExecResult result = container.execInContainer(\n                BIN_PATH,\n                containerInterfaceIP,\n                \"-u\",\n                container.getUsername(),\n                \"-p\",\n                container.getPassword(),\n                \"-k\",\n                container.getKeyspace(),\n                \"-e\",\n                StringUtils.join(statements, \";\")\n            );\n            if (result.getExitCode() != 0) {\n                throw new RuntimeException(result.getStderr());\n            }\n        } catch (Exception e) {\n            log.debug(e.getMessage(), e);\n            throw new UncategorizedScriptException(e.getMessage(), e);\n        }\n    }\n}\n","sourceCodeStart":42,"sourceCodeEnd":68,"githubUrl":"https://github.com/testcontainers/testcontainers-java/blob/8e549514e3f01c57d70546fbb8599d138f3903e5/modules/yugabytedb/src/main/java/org/testcontainers/containers/delegate/YugabyteDBYCQLDelegate.java#L42-L68","documentation":"YugabyteDBYCQLDelegate.execute() runs ycqlsh statements inside the container and throws a RuntimeException containing the process stderr when the ycqlsh exit code is non-zero. This surfaces CQL statement failures from the in-container shell to the test JVM.","triggerScenarios":"Executing CQL init statements via the yugabytedb container's ycqlsh delegate where ycqlsh returns a non-zero exit code (bad CQL syntax, missing keyspace, connection failure inside the container).","commonSituations":"Invalid keyspace name in container config; CQL script with syntax errors; keyspace not yet created when init scripts run; container not fully up.","solutions":["Read the stderr message in the exception to see the exact ycqlsh error","Validate CQL statements before adding them as init scripts","Ensure getKeyspace() names an existing keyspace or create it before running statements","Check the exception's cause chain — it is rethrown as UncategorizedScriptException"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// validate CQL before init\nif (!cql.trim().endsWith(\";\")) throw new IllegalArgumentException(\"CQL statement must end with ;\");","typeGuard":null,"tryCatchPattern":"try { container.withInitScript(\"init.cql\").start(); } catch (RuntimeException e) { log.error(\"ycqlsh failed: {}\", e.getMessage()); throw e; }","preventionTips":["Test init CQL against a local ycqlsh before adding to container config","Ensure the keyspace exists before statements referencing it","Check stderr in the exception message first — it contains the ycqlsh error"],"tags":["yugabytedb","cql","script-execution"],"backgroundTag":"sql-query-failed","analyzedSha":"8e549514e3f01c57d70546fbb8599d138f3903e5","analyzedAt":"2026-09-12T14:56:41.227Z","contentChangedAt":"2026-09-12T14:56:41.227Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}