davila7/claude-code-templates · warning · Error
Invalid session file - no messages found
Error message
Invalid session file - no messages found
What it means
Thrown by validateSessionData() in cli-tool/src/session-sharing.js when the messages array exists but is empty. An export with zero messages carries no conversation content, so cloning it would create a meaningless session file; validation rejects it as the final structural check.
Source
Thrown at cli-tool/src/session-sharing.js:346
* Validate session data structure
* @param {Object} sessionData - Session data to validate
* @throws {Error} If validation fails
*/
validateSessionData(sessionData) {
if (!sessionData.version) {
throw new Error('Invalid session file - missing version');
}
if (!sessionData.conversation || !sessionData.conversation.id) {
throw new Error('Invalid session file - missing conversation data');
}
if (!sessionData.messages || !Array.isArray(sessionData.messages)) {
throw new Error('Invalid session file - missing or invalid messages');
}
if (sessionData.messages.length === 0) {
throw new Error('Invalid session file - no messages found');
}
}
/**
* Install session in Claude Code directory structure
* @param {Object} sessionData - Session data to install
* @param {Object} options - Installation options
* @returns {Promise<Object>} Installation result
*/
async installSession(sessionData, options = {}) {
const homeDir = os.homedir();
const claudeDir = path.join(homeDir, '.claude');
// Determine project directory
const projectName = sessionData.conversation.project || 'shared-session';
const projectDirName = this.sanitizeProjectName(projectName);
// Create project directory structureView on GitHub (pinned to a0851ed10c)
Solutions
- Use a session that actually contains conversation turns
- If you are the sender, verify the export includes messages before sharing
- If privacy filtering stripped messages intentionally, cloning is not meaningful — skip cloneSession
Example fix
// before
if (sessionData.messages.length === 0) {
throw new Error('Invalid session file - no messages found');
}
// after
if (sessionData.messages.length === 0) {
throw new Error('Invalid session file - no messages found (export the session after at least one conversation turn)');
} Defensive patterns
Strategy: validation
Validate before calling
if (data.messages.length === 0) {
console.warn('Session has no messages — cloning would be empty; skipping.');
return null;
} Type guard
function hasMessages(d) {
return Array.isArray(d.messages) && d.messages.length > 0;
} Try / catch
try {
await cloner.cloneSession(data);
} catch (e) {
if (e.message.includes('no messages found')) {
return null; // benign — empty session, nothing to install
}
throw e;
} Prevention
- Only share sessions that contain at least one conversation turn
- Treat an empty-messages session as a warning, not a hard failure, in callers
When it happens
Trigger: Calling cloneSession()/validateSessionData() on a session that was exported before any messages were exchanged, or an export tool that writes structure (version, conversation) but strips the messages.
Common situations: Sharing a brand-new session with no turns yet; privacy-filtered exports that removed all messages; upstream export bug producing an empty array.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- Invalid session file - missing version
- Invalid session file - missing conversation data
- Invalid session file - missing or invalid messages
- Invalid workflow hash format. Expected format: #hash
- Invalid hash format: missing encoded data
AI-assisted analysis of davila7/claude-code-templates@a0851ed10c (2026-08-28).
Data as JSON: /api/errors/fa431d5b340a5110.
Report an issue: GitHub.