deepseek-ai/deepseek-harness · error · WorkspaceMoveInvalidError

cannot move session ' ' in workspace ' ': the session is…

Error message

cannot move session '${sessionId}' in workspace '${record.path}': the session is not accounted

What it means

Move-guard in the workspace entity (WorkspaceMoveInvalidError): insertSessionBefore was asked to move a session id that the workspace's session list does not account. Only tracked members can be reordered.

Solutions

  1. Attach the session to the workspace before trying to move it within the workspace order.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/workspace/workspace/src/entity.ts:154 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of deepseek-ai/deepseek-harness@b150a551b8 (2026-08-24). Data as JSON: /api/errors/8a418d410e95e263. Report an issue: GitHub.

Appendix: source

Thrown at packages/workspace/workspace/src/entity.ts:154

        )
      }
      if (cwd !== this.record.path) {
        throw new Error(
          `cannot attach session '${sessionId}' to workspace '${this.record.path}': `
          + `its cwd resolves to '${cwd}'`,
        )
      }
      this.host.rememberSessionPath(sessionId, cwd)
    }
    await this.mutate(record => record.sessionIds.includes(sessionId)
      ? record
      : { ...record, sessionIds: [sessionId, ...record.sessionIds] })
  }

  async insertSessionBefore(sessionId: SessionId, beforeSessionId?: SessionId): Promise<void> {
    await this.mutate((record) => {
      if (!record.sessionIds.includes(sessionId)) {
        throw new WorkspaceMoveInvalidError(
          `cannot move session '${sessionId}' in workspace '${record.path}': the session is not accounted`,
        )
      }
      if (beforeSessionId !== undefined && !record.sessionIds.includes(beforeSessionId)) {
        throw new WorkspaceMoveInvalidError(
          `cannot move session '${sessionId}' before '${beforeSessionId}' in workspace '${record.path}': `
          + 'the anchor session is not accounted',
        )
      }
      if (beforeSessionId === sessionId) return record
      const without = record.sessionIds.filter(id => id !== sessionId)
      const at = beforeSessionId === undefined ? without.length : without.indexOf(beforeSessionId)
      const sessionIds = [...without.slice(0, at), sessionId, ...without.slice(at)]
      return sessionIds.every((id, index) => id === record.sessionIds[index])
        ? record
        : { ...record, sessionIds }
    })
  }

View on GitHub (pinned to b150a551b8)