Skip to content

fix(cli): handle chat output errors#10229

Merged
mudler merged 1 commit into
mudler:masterfrom
shihyunhuang:fix/cli-chat-golint-error
Jun 9, 2026
Merged

fix(cli): handle chat output errors#10229
mudler merged 1 commit into
mudler:masterfrom
shihyunhuang:fix/cli-chat-golint-error

Conversation

@Oceankj

@Oceankj Oceankj commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Description

This PR fixes errcheck failures in the new CLI chat code.

It updates the terminal chat prompt to propagate write errors instead of ignoring fmt.Fprint* return values, and explicitly ignores the chat stream close error during cleanup where there is no useful follow-up action.

The chat tests were also updated to assert response writer errors in test helpers, so the tests remain explicit while satisfying errcheck.

Notes for Reviewers

  • This is a follow-up cleanup for the interactive CLI chat feature.
  • The behavior is unchanged for normal successful chat sessions.
  • Terminal output failures now return an error from the chat loop instead of being silently ignored.
  • stream.Close() is intentionally ignored in deferred cleanup because request/stream errors are already handled during receive.

Testing

go test -count=1 ./core/cli/chat
go test -count=1 ./core/cli

Assisted-by: Codex:GPT-5
Signed commits

  • Yes, I signed my commits.

Propagate terminal write errors from the chat prompt and explicitly ignore stream close errors during cleanup.

Update chat tests to assert response writer errors so errcheck passes without hiding failed writes.

Tests:
- go test -count=1 ./core/cli/chat
- go test -count=1 ./core/cli

Assisted-by: Codex:GPT-5
Signed-off-by: Ching Kao <0980124jim@gmail.com>
Comment thread core/cli/chat/terminal.go
fmt.Fprintln(out, "bye")
return nil
return writeChat(out, "bye\n")
case "/clear":

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are many literals here, could benefit to move these to constants

@mudler mudler merged commit 48a8ce9 into mudler:master Jun 9, 2026
1 check passed
@localai-bot localai-bot added the bug Something isn't working label Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants