can1357/oh-my-pi · error

Cannot determine repository name from dataset source: ${sour

Error message

Cannot determine repository name from dataset source: ${source}

What it means

repositoryName derives a cache directory name from a dataset source by taking the last path segment (stripping trailing slashes and .git). If the source reduces to an empty basename (e.g. source is '/' or ends with '/.git' collapsing to empty), the cache location cannot be determined, so it throws.

Source

Thrown at packages/metaharness/src/tb/dataset.ts:38

async function validateTasksDir(tasksDir: string): Promise<string> {
	const absolute = path.resolve(tasksDir);
	try {
		const entries = await fs.readdir(absolute, { withFileTypes: true });
		for (const entry of entries) {
			if (!entry.isDirectory()) continue;
			if (await Bun.file(path.join(absolute, entry.name, "task.toml")).exists()) return absolute;
		}
	} catch (error) {
		if (isEnoent(error)) throw new Error(`Terminal-Bench tasks directory does not exist: ${absolute}`);
		throw error;
	}
	throw new Error(`Terminal-Bench tasks directory contains no task.toml files: ${absolute}`);
}

function repositoryName(source: string): string {
	const trimmed = source.replace(/\/+$/, "");
	const basename = trimmed.slice(trimmed.lastIndexOf("/") + 1).replace(/\.git$/, "");
	if (!basename) throw new Error(`Cannot determine repository name from dataset source: ${source}`);
	return basename;
}

function gitError(action: string, source: string, stderr: Uint8Array): Error {
	const detail = new TextDecoder().decode(stderr).trim();
	return new Error(`${action} ${source} failed${detail ? `: ${detail}` : ""}`);
}

export async function resolveDataset(source: string, cacheDir: string): Promise<string> {
	const sourceKind = await directoryStat(source);
	if (sourceKind === "directory") {
		const absoluteSource = path.resolve(source);
		const nestedTasks = path.join(absoluteSource, "tasks");
		const tasksDir = (await directoryStat(nestedTasks)) === "directory" ? nestedTasks : absoluteSource;
		return validateTasksDir(tasksDir);
	}
	if (sourceKind === "other") throw new Error(`Terminal-Bench dataset source is not a directory: ${source}`);

View on GitHub (pinned to 9690622007)

Solutions

  1. Pass a full git URL including the repository name, e.g. https://github.com/owner/repo.git
  2. Fix empty/unexpanded template variables in the script constructing the source
  3. Verify the source string has a non-empty last path segment

Example fix

// before
resolveDataset("https://github.com/laude-institute/")
// after
resolveDataset("https://github.com/laude-institute/terminal-bench.git")
Defensive patterns

Strategy: validation

Validate before calling

function hasBasename(source: string): boolean {
  const trimmed = source.replace(/\/+$/, "");
  return trimmed.slice(trimmed.lastIndexOf("/") + 1).replace(/\.git$/, "").length > 0;
}
if (!hasBasename(source)) throw new Error(`Dataset source needs a repo name: ${source}`);

Prevention

When it happens

Trigger: checkoutDir (via resolveDataset) receives a git URL whose post-processing basename is empty — e.g. source 'https://host/' or a path of only slashes.

Common situations: Config with a truncated URL (host only, no repo path); template variable left empty in a script building the dataset URL.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/01f8c6a05217bc81. Report an issue: GitHub.