deepseek-ai/deepseek-harness · error · Error
cannot attach session
Error message
cannot attach session '${sessionId}' to workspace '${this.record.path}': its cwd '${header.cwd}' is not a directory What it means
Attachment precondition in the workspace entity: the session's stored cwd resolves on disk but stat shows it is not a directory, so it cannot equal a workspace path. The session header is stale or corrupted.
Solutions
- Point the session's cwd at an existing directory, or create the directory, before attaching the session to the workspace.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/workspace/workspace/src/entity.ts:133 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/a466e1e19b8f59cd.
Report an issue: GitHub.
Appendix: source
Thrown at packages/workspace/workspace/src/entity.ts:133
const header = await this.host.readSessionHeader(sessionId)
if (header.cwd === undefined) {
throw new Error(
`cannot attach session '${sessionId}' to workspace '${this.record.path}': `
+ 'its stored header carries no cwd to validate against',
)
}
let cwd: string
try {
cwd = await realpathNormalize(header.cwd)
} catch (error) {
throw new Error(
`cannot attach session '${sessionId}' to workspace '${this.record.path}': `
+ `its cwd '${header.cwd}' does not resolve, so it cannot be validated`,
{ cause: error },
)
}
if (!(await stat(cwd)).isDirectory()) {
throw new Error(
`cannot attach session '${sessionId}' to workspace '${this.record.path}': `
+ `its cwd '${header.cwd}' is not a directory`,
)
}
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> {View on GitHub (pinned to b150a551b8)