Skip to content

NullPointerException in chat/prompt* when no model is selected — crashes all commands including /doctor and /login #304

@myshevchuk

Description

@myshevchuk

Describe the bug

When starting ECA with no provider configured (fresh install, empty or no ~/.config/eca/config.json), every command — including /doctor, /login, and any chat prompt — crashes with a NullPointerException in eca.features.chat/prompt*. The clojure.string/split at chat.clj:1498 receives nil instead of a string (likely the model name), causing Pattern.split to NPE.

This makes it impossible to complete the initial /login flow without a workaround.

To Reproduce

  1. Install eca-emacs, let it auto-download the ECA server
  2. Ensure ~/.config/eca/config.json is either absent or {}
  3. Ensure no cached credentials exist (~/.cache/eca/ has no prior auth)
  4. M-x eca to start
  5. Type /doctor or /login or any text and press RET

Expected behavior

/login shows the provider selection flow; /doctor shows diagnostic info.

Doctor

Doctor command returns the same error.

Workaround

Setting eca-chat-custom-model in Emacs to a valid model name (e.g. "anthropic/claude-sonnet-4.5") before starting ECA allows /login to succeed. After login completes and credentials are cached, the custom model override can be removed.

Root cause

clojure.string/split at chat.clj:1498 is called on a nil value (likely the selected model name) without a nil guard. The prompt* function should either check for nil before splitting or gracefully handle the no-model-selected state, especially for commands like /login and /doctor that don't require a model.

Hence reporting it here and not on eca-emacs.

Additional context
ECA version: 0.101.0 (nightly)
Editor: Emacs 30.2, eca-emacs from MELPA
OS: Fedora 43

**Backtrace**

#error {
:cause nil
:via
[{:type java.lang.NullPointerException
:message nil
:at [java.util.regex.Matcher getTextLength Matcher.java 1806]}]
:trace
[[java.util.regex.Matcher getTextLength Matcher.java 1806]
[java.util.regex.Matcher reset Matcher.java 459]
[java.util.regex.Matcher Matcher.java 255]
[java.util.regex.Pattern matcher Pattern.java 1181]
[java.util.regex.Pattern split Pattern.java 1403]
[java.util.regex.Pattern split Pattern.java 1306]
[clojure.string$split invokeStatic string.clj 227]
[clojure.string$split invoke string.clj 219]
[eca.features.chat$prompt_STAR_ invokeStatic chat.clj 1498]
[eca.features.chat$prompt_STAR_ invoke chat.clj 1417]
[eca.features.chat$prompt invokeStatic chat.clj 1546]
[eca.features.chat$prompt invoke chat.clj 1523]
[eca.handlers$chat_prompt invokeStatic handlers.clj 117]
[eca.handlers$chat_prompt invoke handlers.clj 113]
...]}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions