paperclipai/paperclip · error
Refusing to overwrite
Error message
Refusing to overwrite ${path}: expected hash ${expectedHash} but current hash is ${currentHash} What it means
Error "Refusing to overwrite ${path}: expected hash ${expectedHash} but current hash is ${currentHash}" thrown in paperclipai/paperclip.
Solutions
- Re-read the file to get the current hash, then retry the write with the fresh expectedHash (optimistic concurrency).
When it happens
Trigger: Thrown at packages/plugins/plugin-llm-wiki/src/wiki/core.ts:1762 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of paperclipai/paperclip@5716fe907e (2026-08-18).
Data as JSON: /api/errors/d5e8ce78c233ef44.
Report an issue: GitHub.
Appendix: source
Thrown at packages/plugins/plugin-llm-wiki/src/wiki/core.ts:1761
function mergeLocalSourceRows(sources: WikiSourceRow[], entries: PluginLocalFolderEntry[]): WikiSourceRow[] {
const byPath = new Map(sources.map((source) => [source.rawPath, source]));
for (const entry of entries) {
if (!entry.path.endsWith(".md") || byPath.has(entry.path)) continue;
byPath.set(entry.path, {
rawPath: entry.path,
title: null,
sourceType: "local_file",
url: null,
status: "present",
createdAt: entry.modifiedAt ?? new Date(0).toISOString(),
});
}
return [...byPath.values()].sort((a, b) => a.rawPath.localeCompare(b.rawPath));
}
function assertExpectedHash(expectedHash: string | null | undefined, currentHash: string | null, path: string): void {
if (expectedHash && currentHash && expectedHash !== currentHash) {
throw new Error(`Refusing to overwrite ${path}: expected hash ${expectedHash} but current hash is ${currentHash}`);
}
}
async function upsertWikiInstance(ctx: PluginContext, input: { companyId: string; wikiId: string; rootPath?: string | null }) {
await ctx.db.execute(
`INSERT INTO ${tableName(ctx.db.namespace, "wiki_instances")} AS wiki_instances
(id, company_id, wiki_id, root_folder_key, configured_root_path, schema_version, settings, managed_agent_key, managed_project_key)
VALUES ($1, $2, $3, $4, $5, 1, '{}'::jsonb, $6, $7)
ON CONFLICT (company_id, wiki_id)
DO UPDATE SET configured_root_path = COALESCE(EXCLUDED.configured_root_path, wiki_instances.configured_root_path),
managed_agent_key = EXCLUDED.managed_agent_key,
managed_project_key = EXCLUDED.managed_project_key,
updated_at = now()`,
[
randomUUID(),
input.companyId,
input.wikiId,
WIKI_ROOT_FOLDER_KEY,View on GitHub (pinned to 5716fe907e)