From 99e05f878fc0c0fa9ed02c7b3820d348e1cf0572 Mon Sep 17 00:00:00 2001 From: 035966-L3 <139025318+035966-L3@users.noreply.github.com> Date: Wed, 1 Oct 2025 15:49:22 +0800 Subject: [PATCH] core: fix: ProblemAlreadyExistError should be thrown with the new PID, not the old one (#1052) --- packages/hydrooj/src/handler/problem.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/hydrooj/src/handler/problem.ts b/packages/hydrooj/src/handler/problem.ts index 13455e0f8..122f68684 100644 --- a/packages/hydrooj/src/handler/problem.ts +++ b/packages/hydrooj/src/handler/problem.ts @@ -616,7 +616,7 @@ export class ProblemEditHandler extends ProblemManageHandler { newPid: string | number = '', hidden = false, tag: string[] = [], difficulty = 0, ) { if (typeof newPid !== 'string') newPid = `P${newPid}`; - if (newPid !== this.pdoc.pid && await problem.get(domainId, newPid)) throw new ProblemAlreadyExistError(pid); + if (newPid !== this.pdoc.pid && await problem.get(domainId, newPid)) throw new ProblemAlreadyExistError(newPid); const $update: Partial = { title, content, pid: newPid, hidden, tag: tag ?? [], difficulty, html: false, };