Skip to content

Bug: OpenCode provider silently skips all sessions due to fingerprintFile2 failing on SQLite path format #360

@jack61714z

Description

@jack61714z

Description

The OpenCode provider discovers sessions correctly but fingerprintFile2() fails to stat() them because the source path format includes a colon-separated session ID suffix (e.g. opencode.db:ses_abc123). This causes all sessions to be silently skipped, reporting $0.00 / 0 calls.

Root Cause

In parseProviderSources()fingerprintFile2(), the path is passed directly to fs.stat(). For SQLite-based providers (OpenCode, potentially Cursor), the source path format is dbPath:sessionId (set in discoverFromDb2):

// discoverFromDb2 sets path as:
return {
  path: `${dbPath}:${row.id}`,  // e.g. "/path/to/opencode.db:ses_xxx"
  ...
};

fingerprintFile2 tries stat("/path/to/opencode.db:ses_xxx") which fails → returns nullif (!fp) continue skips the session.

Workaround / Fix

In fingerprintFile2, add a fallback that strips the :sessionId suffix when stat() fails:

async function fingerprintFile2(filePath) {
  try {
    const s = await stat21(filePath);
    return { dev: s.dev, ino: s.ino, mtimeMs: s.mtimeMs, sizeBytes: s.size };
  } catch {
    // Fallback for SQLite-based providers with colon-separated session IDs
    const lastColon = filePath.lastIndexOf(":");
    if (lastColon > 0) {
      try {
        const basePath = filePath.slice(0, lastColon);
        const s2 = await stat21(basePath);
        return { dev: s2.dev, ino: s2.ino, mtimeMs: s2.mtimeMs, sizeBytes: s2.size };
      } catch {}
    }
    return null;
  }
}

Environment

  • codeburn v0.9.9 (npm)
  • Node.js v22.18.0 (node:sqlite available)
  • macOS 15 / darwin
  • OpenCode SQLite DB: ~/.local/share/opencode/opencode.db (~1 GB, 16K+ sessions)

Impact

  • OpenCode provider shows $0.00 for all periods
  • After patch: correctly reports Today $0.39 / 198 calls, Month $34.83 / 1,642 calls

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions