-
Notifications
You must be signed in to change notification settings - Fork 19
fix: suppress console logging that corrupts TUI display #269
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /** | ||
| * In-memory ring buffer for dbt log messages. | ||
| * | ||
| * Captures dbt-integration library logging without writing to stdout/stderr, | ||
| * which would corrupt the TUI display (see #249). Buffered logs can be | ||
| * retrieved for diagnostics via getRecentDbtLogs(). | ||
| */ | ||
|
|
||
| const DBT_LOG_BUFFER_SIZE = 100 | ||
| const dbtLogBuffer: string[] = [] | ||
|
|
||
| export function bufferLog(msg: string): void { | ||
| if (dbtLogBuffer.length >= DBT_LOG_BUFFER_SIZE) { | ||
| dbtLogBuffer.shift() | ||
| } | ||
| dbtLogBuffer.push(msg) | ||
| } | ||
|
|
||
| /** Retrieve recent dbt log messages (for diagnostics / error reporting). */ | ||
| export function getRecentDbtLogs(): string[] { | ||
| return [...dbtLogBuffer] | ||
| } | ||
|
|
||
| /** Clear buffered logs (call on session/adapter reset). */ | ||
| export function clearDbtLogs(): void { | ||
| dbtLogBuffer.length = 0 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| import { describe, test, expect, beforeEach } from "bun:test" | ||
| import { bufferLog, getRecentDbtLogs, clearDbtLogs } from "../src/log-buffer" | ||
|
|
||
| describe("dbt log buffer", () => { | ||
| beforeEach(() => { | ||
| clearDbtLogs() | ||
| }) | ||
|
|
||
| test("starts empty", () => { | ||
| expect(getRecentDbtLogs()).toEqual([]) | ||
| }) | ||
|
|
||
| test("buffers log messages", () => { | ||
| bufferLog("[dbt] compiling model") | ||
| bufferLog("[dbt:warn] deprecation notice") | ||
| expect(getRecentDbtLogs()).toEqual([ | ||
| "[dbt] compiling model", | ||
| "[dbt:warn] deprecation notice", | ||
| ]) | ||
| }) | ||
|
|
||
| test("returns a copy, not a reference", () => { | ||
| bufferLog("test") | ||
| const logs = getRecentDbtLogs() | ||
| logs.push("injected") | ||
| expect(getRecentDbtLogs()).toEqual(["test"]) | ||
| }) | ||
|
|
||
| test("caps at 100 entries (FIFO)", () => { | ||
| for (let i = 0; i < 120; i++) { | ||
| bufferLog(`msg-${i}`) | ||
| } | ||
| const logs = getRecentDbtLogs() | ||
| expect(logs.length).toBe(100) | ||
| expect(logs[0]).toBe("msg-20") | ||
| expect(logs[99]).toBe("msg-119") | ||
| }) | ||
|
|
||
| test("never exceeds buffer size", () => { | ||
| for (let i = 0; i < 200; i++) { | ||
| bufferLog(`msg-${i}`) | ||
| // Buffer should never exceed 100 entries at any point | ||
| expect(getRecentDbtLogs().length).toBeLessThanOrEqual(100) | ||
| } | ||
| }) | ||
|
|
||
| test("clearDbtLogs empties the buffer", () => { | ||
| bufferLog("a") | ||
| bufferLog("b") | ||
| clearDbtLogs() | ||
| expect(getRecentDbtLogs()).toEqual([]) | ||
| }) | ||
|
|
||
| test("can buffer again after clearing", () => { | ||
| bufferLog("old") | ||
| clearDbtLogs() | ||
| bufferLog("new") | ||
| expect(getRecentDbtLogs()).toEqual(["new"]) | ||
| }) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 thecatchblocks or after detecting a failure viastderr, these callers should invokegetRecentDbtLogs()and log the retrieved error messages to provide necessary diagnostic information.Prompt for AI Agent
Did we get this right? 👍 / 👎 to inform future reviews.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Addressed in commit 2d36571 —
getRecentDbtLogs()is now wired into thebail()error handler inindex.ts, so buffered logs are included in diagnostic JSON output on failure. The buffer was also extracted to its ownlog-buffer.tsmodule with 7 unit tests.