Skip to content

SQLiteError: bad parameter or other API misuse #15221

Closed as not planned
Closed as not planned

Description

@starsolaris

Description

After send prompt, I do not receive any response while opencode show progress indicator.
On opencode close

18 |    }
19 |    exec(query) {
20 |            this.client.exec(query);
21 |    }
22 |    prepareQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper) {
23 |            return new PreparedQuery(this.client.prepare(query.sql), query, this.logger, fields, executeMethod, isResponseInArrayMode, customResultMapper);
                                            ^
SQLiteError: bad parameter or other API misuse
      errno: 21,
 byteOffset: -1,
       code: "SQLITE_MISUSE"

      at prepare (bun:sqlite:345:37)
      at prepareQuery (../../node_modules/.bun/[email protected]+1f516382cd87cd66/node_modules/drizzle-orm/bun-sqlite/session.js:23:40)
      at _prepare (../../node_modules/.bun/[email protected]+1f516382cd87cd66/node_modules/drizzle-orm/sqlite-core/query-builders/select.js:558:71)
      at all (../../node_modules/.bun/[email protected]+1f516382cd87cd66/node_modules/drizzle-orm/sqlite-core/query-builders/select.js:584:15)
      at run (node:async_hooks:62:22)
      at use (src/storage/db.ts:124:28)
      at <anonymous> (src/session/message-v2.ts:770:27)
      at process (src/session/processor.ts:393:37)

After next run it can work, or not, i do not find correct scenario.

Plugins

oh-my-opencode

OpenCode version

1.2.15

Steps to reproduce

No response

Screenshot and/or share link

No response

Operating System

Ubuntu 24.04.3 LTS inside wsl2, Windows 10

Terminal

Windows Terminal

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Feb 26, 2026
  2. gp27 commented on Mar 1, 2026

    @gp27

    I am experiencing the same issue. The error log and stack trace are verbatim to those posted by starsolaris.

    The ui of the session freezes, but the agent starts working in background.

    If I switch to other sessions and i get back to the first one, it does not update. However if i restart opencode and switch back to the previous session i can then see that session history

    I am on [email protected]

    Updates:

    • the issue happens only if start opencode with a folder argument:
      cd repos/my-project && opencode // this works fine
      opencode repos/my-project // this session has the problem I just described
    • the sqlite error seems to be just a consequence of opencode being closed while the agent was still running. If i give a very simple prompt like echo hello world and wait a few seconds, the history still doesn't get updated, but closing opencode doesn't product the error and stack trace
  3. egilewski commented on Mar 1, 2026

    @egilewski

    I have a reproduction of SQLITE_MISUSE for Linux, though it may be just half the problem from the initial comment.

    Environment:

    1. Debian Testing
    2. Freshly installed OpenCode 1.2.15 – no plugins, no config
    3. agent Build, Big Pickle
    4. Kitty
    5. Zsh
    6. current directory is empty

    Steps:

    1. run opencode
    2. when it's ready, type something and press enter
    3. immediately press ctrl-c (no extreme hurry needed)

    Opencode immediately exits with exit code 0. Complete output:

    
                                       ▄     
      █▀▀█ █▀▀█ █▀▀█ █▀▀▄ █▀▀▀ █▀▀█ █▀▀█ █▀▀█
      █  █ █  █ █▀▀▀ █  █ █    █  █ █  █ █▀▀▀
      ▀▀▀▀ █▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀ ▀▀▀▀
    
      Session   New session - 2026-03-01T15:08:47.701Z
      Continue  opencode -s ses_3560e1d2affeJ6vMNY96biZZZZ
    
      | 	}
     | 	exec(query) {
    20 | 		this.client.exec(query);
    21 | 	}
      | 	prepareQuery(query, fields, executeMethod, isResponseInArrayMode, customResultMapper) {
     | 		return new PreparedQuery(this.client.prepare(query.sql), query, this.logger, fields, executeMethod, isResponseInArrayMode, customResultMapper);
                                                ^
    SQLiteError: bad parameter or other API misuse
          errno: 21,
     byteOffset: -1,
           code: "SQLITE_MISUSE"
    
          at prepare (bun:sqlite:345:37)
          at prepareQuery (../../node_modules/.bun/[email protected]+1f516382cd87cd66/node_modules/drizzle-orm/bun-sqlite/session.js:23:40)
          at _prepare (../../node_modules/.bun/[email protected]+1f516382cd87cd66/node_modules/drizzle-orm/sqlite-core/query-builders/select.js:558:71)
          at all (../../node_modules/.bun/[email protected]+1f516382cd87cd66/node_modules/drizzle-orm/sqlite-core/query-builders/select.js:584:15)
          at run (node:async_hooks:62:22)
          at use (src/storage/db.ts:124:28)
          at <anonymous> (src/session/message-v2.ts:770:27)
          at process (src/session/processor.ts:393:37)
    

    I see #13633 was supposed to fix this, but something went wrong.

  4. marcospb19 commented on Mar 2, 2026

    @marcospb19

    Same on Linux, not Windows specific.

    SQLiteError: bad parameter or other API misuse
          errno: 21,
     byteOffset: -1,
           code: "SQLITE_MISUSE"
    

    reproduced on 1.2.10 and 1.2.15
    reproduced with different models

  5. marcospb19 commented on Mar 2, 2026

    @marcospb19

    EDIT: Sorry, problem also present in 1.2.7

  6. FurkanDGN commented on Mar 3, 2026

    @FurkanDGN

    In my scenario, this issue occurred when I experienced a network connection problem.
    Version: 1.2.15

  7. assigned and unassigned on Apr 26, 2026
  8. removed
    bugSomething isn't working
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  9. github-actions commented on Jul 4, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions