Skip to content

fix: format object prompt errors#255

Merged
0xmrpeter merged 1 commit into
Open-ACP:mainfrom
civonafets:fix/session-prompt-error-object
May 18, 2026
Merged

fix: format object prompt errors#255
0xmrpeter merged 1 commit into
Open-ACP:mainfrom
civonafets:fix/session-prompt-error-object

Conversation

@civonafets
Copy link
Copy Markdown
Contributor

@civonafets civonafets commented May 9, 2026

Summary

Prompt failures can be rejected with plain objects instead of Error instances. This PR formats those values into useful messages so users do not see Prompt execution failed: [object Object].

Related Issues

None.

Type of Change

  • Bug fix
  • New feature
  • New adapter / plugin
  • Documentation
  • Refactor (no functional change)
  • Performance improvement
  • Tests
  • CI / Build / Config

Changes Made

  • Added prompt error formatting for strings, Error instances, primitive values, nested error objects, and JSON-RPC error data.
  • Preserved a stable fallback for circular or uninformative error objects.
  • Added session tests for plain object errors, JSON-RPC error data, and fallback formatting.

Testing

  • Ran pnpm test — all tests pass
  • Tested manually with:
  • Added new tests for this change
  • No tests needed (explain why)

Commands run:

PATH=/Users/m/.nvm/versions/node/v24.15.0/bin:$PATH corepack pnpm build
HOME=/private/tmp/openacp-pr-home PATH=/Users/m/.nvm/versions/node/v24.15.0/bin:$PATH corepack pnpm test

Note: HOME was set to a writable temp directory for the full test run because this local sandbox blocks writes under /Users/m.

Platform Impact

  • Telegram
  • Discord
  • Slack
  • CLI
  • REST API
  • Web UI
  • All / Core

Screenshots / Recordings

Not applicable.

Checklist

  • My code follows the project's TypeScript conventions (ESM, .js extensions)
  • I have updated relevant documentation (if needed)
  • I have added/updated tests (if applicable)
  • My changes don't introduce new warnings or errors
  • I have run pnpm build successfully
  • My changes are backward compatible with existing config and data formats
  • Plugin API / PluginContext not changed; plugin template update not needed

@0xmrpeter
Copy link
Copy Markdown
Contributor

Thank you for the contribution! This is a real and annoying bug — [object Object] in error messages is never helpful to users, and the recursive extraction approach handles the JSON-RPC case and circular references correctly.

Approved for merge. I'll fix a couple of minor issues in a follow-up commit:

  • "message" in the traversal loop is redundant — if (direct) return direct at the end already handles the fallback. This doesn't affect behavior but makes the code harder to reason about.
  • isGenericPromptErrorMessage is missing a comment explaining why "Internal error" is considered generic (it's a JSON-RPC -32603 message, not a meaningful user-facing error). Without that context, future readers may not understand the intent.

These are non-blocking — merging now and fixing in a follow-up.

@0xmrpeter 0xmrpeter merged commit 4f76445 into Open-ACP:main May 18, 2026
4 checks passed
@civonafets
Copy link
Copy Markdown
Contributor Author

civonafets commented May 18, 2026 via email

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.

2 participants