{"record":{"id":"b6c816d927c6c0e1","repo":"apache/cassandra","slug":"text","errorCode":null,"errorMessage":"text","messagePattern":"text","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"info","filePath":"src/java/org/apache/cassandra/service/ClientWarn.java","lineNumber":46,"sourceCode":"    private static final String TRUNCATED = \" [truncated]\";\n    public static ClientWarn instance = new ClientWarn();\n\n    private ClientWarn()\n    {\n    }\n\n    public State get()\n    {\n        return ExecutorLocals.current().clientWarnState;\n    }\n\n    public void set(State value)\n    {\n        ExecutorLocals current = ExecutorLocals.current();\n        ExecutorLocals.Impl.set(current.traceState, value, current.eligibleForArtificialLatency);\n    }\n\n    public void warn(String text)\n    {\n        State state = get();\n        if (state != null)\n            state.add(text);\n    }\n\n    public void captureWarnings()\n    {\n        set(new State());\n    }\n\n    /**\n     * Provides an additional control on capturing warnings. When executing SchemaTransformations in the\n     * metadata log follower or when committing on a CMS member, we don't want these to be triggered.\n     * @see org.apache.cassandra.schema.SchemaTransformation#enterExecution()\n     **/\n    public void pauseCapture()\n    {","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/ClientWarn.java#L28-L64","documentation":"ClientWarn.warn queues a warning message (the `text` parameter) into the per-request warn/warnedTables state that is returned to drivers in the response's Warnings frame. If no warning state is attached to the current execution (state == null), the warning is silently dropped.","triggerScenarios":"Server code calls ClientWarn.instance.warn(text) during query execution; the warning only reaches the client when the ExecutorLocals/ClientState state for the current thread carries a warning State (normal query execution), and it is absent when running outside a client request context.","commonSituations":"Internal/background code paths (compaction, repair, tooling) that reuse query machinery and invoke warn() with no client attached — warnings vanish; users wondering why a warning from a server-side operation never appears in their driver.","solutions":["If the warning is expected client-side, execute it through a normal query path so ClientWarn state exists; nothing to fix in caller code","For internal code, log via the logger instead of ClientWarn.warn when no client context is present","Check driver logs / QueryWarnings (e.g. driver's warning handler) to consume warnings — unhandled client warnings are easy to miss"],"exampleFix":"// before\nClientWarn.instance.warn(msg); // dropped off-request\n// after\nif (ClientWarn.instance.get() != null) ClientWarn.instance.warn(msg);\nelse logger.warn(msg);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":"// only warn when a client context exists\nState state = ClientWarn.instance.get();\nif (state != null) ClientWarn.instance.warn(text); else logger.warn(text);","tryCatchPattern":"// server-side guard: fall back to logger when no client is attached\ntry {\n    ClientWarn.instance.warn(text);\n} catch (Exception e) {\n    logger.warn(\"Could not deliver warning to client: {}\", text, e);\n}","preventionTips":["Register a driver warning handler to actually consume server warnings","Don't rely on ClientWarn for internal/background code paths — use the logger","Remember ClientWarn state is thread-local via ExecutorLocals; async code must propagate locals"],"tags":["warnings","client-warn","request-context"],"backgroundTag":"unexpected-api-response-shape","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}