affaan-m/ECC · error · Error
Unsupported OpenCode session target
Error message
Unsupported OpenCode session target: ${target} What it means
Terminal guard of resolveSessionInfoPath: the target string is neither 'latest', a resolvable session id, nor a recognized OpenCode session file path, so the adapter rejects it. This is the OpenCode unsupported-target error.
Solutions
- Use 'latest', a valid session id, or an existing OpenCode session file path.
- Confirm the path points to a session info file (not a directory or message file).
- Trim and log the target value to catch empty/misquoted input.
- Dispatch to the correct adapter for Claude/Codex targets.
- Verify cwd for relative paths.
Example fix
// before
resolve(targetFromEnv); // may be '' -> throws
// after
const t = (targetFromEnv || '').trim();
if (!t || (t !== 'latest' && !fs.existsSync(t))) {
throw new Error(`OPENCODE_TARGET='${targetFromEnv}' is not 'latest', a session id, or an existing session file`);
}
resolve(t); Defensive patterns
Strategy: validation
Validate before calling
if (typeof target !== 'string' || !target.trim()) throw new Error('OpenCode target must be a non-empty string');
if (target !== 'latest' && !fs.existsSync(target)) throw new Error(`OpenCode target '${target}' not 'latest' or an existing file`); Type guard
function isValidOpencodeTarget(t) { return t === 'latest' || (typeof t === 'string' && t.trim().length > 0); } Try / catch
try { return adapter.resolveSessionInfoPath(target); } catch (e) { if (/^Unsupported OpenCode session target:/.test(e.message)) console.error(`Valid forms: 'latest', session id, session file path; got '${target}'`); throw e; } Prevention
- Validate the three accepted target forms upstream
- Guard against unset env vars yielding empty strings
- Dispatch Claude/Codex targets to their own adapters
- Log raw values to catch quoting issues
When it happens
Trigger: resolveSessionInfoPath called with '', a directory path, a Claude/Codex session path, or any value isOpencodeSessionFileTarget(target, cwd) rejects, with explicitTarget null or unresolvable.
Common situations: Routing a session file from another harness to the OpenCode adapter; empty config value from an unset env var; passing a directory instead of a session file; relative path resolved from an unexpected cwd.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- No OpenCode sessions found
- OpenCode session not found
- Unsupported Claude session target
- Unsupported Codex session target
- Cannot delete active session
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/160410afaeefe976.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/lib/session-adapters/opencode.js:154
const absoluteExplicit = path.resolve(cwd, explicitTarget);
if (fs.existsSync(absoluteExplicit) && isSessionInfoFile(absoluteExplicit)) {
return { sessionInfoPath: absoluteExplicit, sourceTarget: { type: 'opencode-session-file', value: absoluteExplicit } };
}
const byId = findSessionInfoById(storageDir, explicitTarget);
if (byId) {
return { sessionInfoPath: byId, sourceTarget: { type: 'opencode', value: explicitTarget } };
}
throw new Error(`OpenCode session not found: ${explicitTarget}`);
}
if (isOpencodeSessionFileTarget(target, cwd)) {
const absoluteTarget = path.resolve(cwd, target);
return { sessionInfoPath: absoluteTarget, sourceTarget: { type: 'opencode-session-file', value: absoluteTarget } };
}
throw new Error(`Unsupported OpenCode session target: ${target}`);
}
function readMessageFiles(messageDir) {
if (!fs.existsSync(messageDir) || !fs.statSync(messageDir).isDirectory()) {
return [];
}
try {
return fs.readdirSync(messageDir)
.filter(name => name.startsWith('msg_') && name.endsWith('.json'))
.map(name => path.join(messageDir, name));
} catch {
return [];
}
}
function deriveModelFromMessages(messageFiles) {
for (const filePath of messageFiles.slice(0, MAX_MESSAGE_SCAN)) {View on GitHub (pinned to 8321021c54)