Skip to content

fix(assistants): improve error logging in chat to show actual error details - #537

Open
gokhanozdemir wants to merge 8 commits into
codemie-ai:mainfrom
gokhanozdemir:fix/499-assistant-chat-error-logging
Open

gokhanozdemir wants to merge 8 commits into
codemie-ai:mainfrom
gokhanozdemir:fix/499-assistant-chat-error-logging

Conversation

@gokhanozdemir

@gokhanozdemir gokhanozdemir commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Errors thrown during assistants chat were serialized as [object Object], hiding the actual message, name, code, and stack trace needed for debugging, and could be mistaken for an authentication error.

Root cause: logger.error(message, error) only unwraps .message/.stack when the second argument is an actual Error instance. Any plain object — including the structured context produced by createErrorContext() — fell through to String(error), which yields [object Object].

Fixes #499

Changes

  • src/utils/logger.ts: added formatNonErrorValue() and used it in Logger.error()'s non-Error branch (both the file-log and console-log paths) so plain objects are JSON.stringify'd instead of String()-ed. This fixes the bug at its source for every caller, including the existing logger.error('Assistant chat API call failed', context) call in handleChatError.

Impact

Error output during assistants chat failures (and any other logger.error() call site passing a non-Error object) now shows actionable detail instead of [object Object]; no change to normal (non-error) behavior.

Checklist

  • Self-reviewed
  • Manual testing performed
  • Documentation updated (if needed)
  • No breaking changes (or clearly documented)

@gokhanozdemir
gokhanozdemir force-pushed the fix/499-assistant-chat-error-logging branch from e1e7c8f to 38b9eb4 Compare September 5, 2026 17:08
…etails

Fixes codemie-ai#499 - Serialize error objects properly to capture message, name, code, and stack trace for debugging.
@gokhanozdemir
gokhanozdemir force-pushed the fix/499-assistant-chat-error-logging branch from 38b9eb4 to bbd923a Compare September 5, 2026 17:33
@gokhanozdemir
gokhanozdemir marked this pull request as ready for review September 5, 2026 17:50
@gokhanozdemir
gokhanozdemir marked this pull request as draft September 15, 2026 06:43
gokhanozdemir and others added 5 commits September 15, 2026 17:58
… handle errors gracefully"

This reverts commit a161f3d.
…bject]

logger.error() only unwrapped .message/.stack for actual Error instances;
any plain object (including the context built by createErrorContext)
fell through to String(error), producing [object Object] in both the
console and the debug log file. The previous fix attempt in handleChatError
re-triggered the same bug by passing a new plain object literal through the
same code path, so it's removed in favor of fixing the root cause once.

Generated with AI

Co-Authored-By: codemie-ai <[email protected]>

@gokhanozdemir gokhanozdemir left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

self reviewed

@gokhanozdemir
gokhanozdemir marked this pull request as ready for review September 15, 2026 15:22
@8nevil8

8nevil8 commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

@gokhanozdemir pls provide screenshot with cli screen with state after fix. how error looks like

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

codemie assistants chat fails with misleading "Authentication expired" error despite valid, freshly-refreshed SSO session

2 participants