earendil-works/pi · error

Entry not found

Error message

Entry ${leafId} not found

What it means

Guard in createBranchedSession: getBranch(leafId) returned an empty path, meaning the given leaf entry id is not reachable from the root (typically not present in the session at all). The extraction of a root-to-leaf conversation path cannot proceed.

Solutions

  1. Pass the id of an existing entry (commonly the current leafId) in the same session
  2. If the session was reloaded or switched, re-query valid ids via getTree()
  3. Verify the id was not copied from another session file
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/coding-agent/src/core/session-manager.ts:1417 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24). Data as JSON: /api/errors/2b22139f59dfc5f8. Report an issue: GitHub.

Appendix: source

Thrown at packages/coding-agent/src/core/session-manager.ts:1417

			summary,
			details,
			usage,
			fromHook,
		};
		this._appendEntry(entry);
		return entry.id;
	}

	/**
	 * Create a new session file containing only the path from root to the specified leaf.
	 * Useful for extracting a single conversation path from a branched session.
	 * Returns the new session file path, or undefined if not persisting.
	 */
	createBranchedSession(leafId: string): string | undefined {
		const previousSessionFile = this.sessionFile;
		const path = this.getBranch(leafId);
		if (path.length === 0) {
			throw new Error(`Entry ${leafId} not found`);
		}

		// Filter out LabelEntry from path - we'll recreate them from the resolved map.
		// Because labels are real tree entries, later entries can be children of labels;
		// removing labels requires re-chaining the retained path to avoid orphaned subtrees.
		const pathWithoutLabels: SessionEntry[] = [];
		let pathParentId: string | null = null;
		for (const entry of path) {
			if (entry.type === "label") continue;
			pathWithoutLabels.push({ ...entry, parentId: pathParentId });
			pathParentId = entry.id;
		}

		const newSessionId = createSessionId();
		const timestamp = new Date().toISOString();
		const fileTimestamp = timestamp.replace(/[:.]/g, "-");
		const newSessionFile = join(this.getSessionDir(), `${fileTimestamp}_${newSessionId}.jsonl`);

View on GitHub (pinned to 4af9d21d3b)