fix: suppress console logging that corrupts TUI display#269
fix: suppress console logging that corrupts TUI display#269anandgupta42 merged 2 commits intomainfrom
Conversation
…TUI display (#249) - `snowflake-sdk`: configure Winston log level to OFF (was writing JSON to stdout) - `@databricks/sql`: create `DBSQLLogger` with error-only level (Winston console transport) - `dbt-tools` adapter: replace `console.error` calls with in-memory ring buffer - Tracing module: route `console.debug`/`console.warn` through `Log.Default` (log file only) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
| log: (msg: string) => bufferLog(`[dbt] ${msg}`), | ||
| trace: () => {}, | ||
| debug: () => {}, |
There was a problem hiding this comment.
Bug: Error logs from dbt operations are now buffered but never retrieved, as the new getRecentDbtLogs() function is never called. This results in silent failures with no diagnostic output.
Severity: HIGH
Suggested Fix
The code that calls dbt operations and handles their failures (e.g., in tryExecuteViaDbt() or CLI command handlers) must be updated. In the catch blocks or after detecting a failure via stderr, these callers should invoke getRecentDbtLogs() and log the retrieved error messages to provide necessary diagnostic information.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: packages/dbt-tools/src/adapter.ts#L79-L81
Potential issue: The modification to the dbt adapter's `terminal()` function routes all
error logs into an in-memory buffer, `dbtLogBuffer`, instead of `console.error`. While a
new function, `getRecentDbtLogs()`, was added to retrieve these buffered logs, it is
never called anywhere in the codebase. As a result, when any dbt operation fails (e.g.,
in `tryExecuteViaDbt()` or CLI commands), the error messages are silently buffered and
lost. This completely removes error visibility for debugging dbt failures, as the
diagnostic information is never retrieved or displayed to the user or developer.
Did we get this right? 👍 / 👎 to inform future reviews.
There was a problem hiding this comment.
Addressed in commit 2d36571 — getRecentDbtLogs() is now wired into the bail() error handler in index.ts, so buffered logs are included in diagnostic JSON output on failure. The buffer was also extracted to its own log-buffer.ts module with 7 unit tests.
- Extract dbt log buffer into `log-buffer.ts` for testable isolation
- Wire `getRecentDbtLogs()` into `bail()` error path so buffered logs
are included in diagnostic output instead of being silently lost
- Add `clearDbtLogs()` for session isolation
- Fix buffer order: evict before push (never exceeds `DBT_LOG_BUFFER_SIZE`)
- Databricks: use no-op logger `{ log: () => {} }` instead of
`DBSQLLogger({ level: "error" })` for complete stdout suppression
- Snowflake: check `typeof configure === "function"` before calling
- Add 7 unit tests for buffer behavior (FIFO, cap, clear, copy semantics)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
What does this PR do?
Fixes raw JSON log lines from third-party libraries (e.g.
{"level":"INFO","message":"Creating new connection object"}) leaking into the chat UI, corrupting the TUI display. Suppresses console output from 4 sources:snowflake-sdk: Winston logger withadditionalLogToConsole=trueby default → setlogLevel: "OFF"@databricks/sql: Winston Console transport atinfolevel → createDBSQLLoggerwitherror-only leveldbt-toolsadapter:console.error("[dbt]", msg)on every dbt operation → buffer in memory ring bufferconsole.debug/console.warnon trace errors → route throughLog.Default(log file only)Type of change
Issue for this PR
Closes #249
How did you verify your code works?
snowflake-sdkand@databricks/sqlboth use Winston Console transport by default (verified innode_modulessource)dbt-toolsadapter writesconsole.erroron every dbt-integration callbackconsole.debug/console.warncallsturbo typecheckChecklist
🤖 Generated with Claude Code