datawhalechina/hello-agents · error · Error

删除失败:

Error message

删除失败: 

What it means

'删除失败: ' + e (delete failed) is alerted by the NovelGenerator frontend when DELETE {API_URL}/outline/delete?novel_id=&title=&note_id= responds non-OK; the thrown Error wraps the response text. Deletion passes identifiers purely in the query string, so any missing/unknown id produces a server 404 that surfaces here.

Source

Thrown at Co-creation-projects/lgs-only-NovelGenerator/frontend/index.html:434

                        loading.value = false;
                        currentAction.value = null;
                    }
                };

                const deleteOutline = async () => {
                    if(!confirm('确定要删除当前大纲吗?此操作不可恢复。')) return;
                    loading.value = true;
                    currentAction.value = 'delete_outline';
                    try {
                        const params = new URLSearchParams({
                            novel_id: project.novel_id,
                            title: project.title,
                            note_id: outline.id
                        });
                        const res = await fetch(`${API_URL}/outline/delete?${params.toString()}`, {
                            method: 'DELETE'
                        });
                        if (!res.ok) throw new Error(await res.text());
                        
                        outline.id = null;
                        outline.content = '';
                        alert('大纲已删除');
                    } catch (e) {
                        alert('删除失败: ' + e);
                    } finally {
                        loading.value = false;
                        currentAction.value = null;
                    }
                };

                const generateChapters = async () => {
                    loading.value = true;
                    currentAction.value = 'chapter';
                    lastGeneratedChapter.value = null;
                    
                    try {

View on GitHub (pinned to 606a07d341)

Solutions

  1. Guard the action: return early if !outline.id instead of sending a doomed request.
  2. Read the alert body text — 'not found' means treat as success (refresh local state) or inform the user the outline was already gone.
  3. Handle 404 idempotently: clear local outline state anyway since the goal (outline gone) is achieved.
  4. Verify project (novel_id/title) is initialized before any outline operation.

Example fix

// before
if(!confirm('确定要删除当前大纲吗?此操作不可恢复。')) return;
// ...fetch delete

// after
if(!confirm('确定要删除当前大纲吗?此操作不可恢复。')) return;
if (!outline.id) { outline.content = ''; return; }
// ...fetch delete; on !res.ok && res.status === 404 treat as deleted
Defensive patterns

Strategy: try-catch

Validate before calling

if (!outline.id) {
  // nothing to delete server-side; just clear local state
  outline.id = null;
  outline.content = '';
  return;
}

Try / catch

try {
  const res = await fetch(`${API_URL}/outline/delete?${params}`, { method: 'DELETE' });
  if (!res.ok && res.status !== 404) throw new Error(`${res.status}: ${(await res.text()).slice(0, 200)}`);
  outline.id = null;
  outline.content = '';
  alert('大纲已删除');
} catch (e) {
  alert('删除失败: ' + (e instanceof Error ? e.message : String(e)));
}

Prevention

When it happens

Trigger: DELETE /outline/delete returns 404 when outline.id is stale (backend store reset, note already deleted) or null (delete invoked when no outline exists — the confirm dialog passes but the request then fails); 422 when novel_id/title are empty because project wasn't initialized; 500 on storage errors.

Common situations: Double-clicking delete (second request 404s because the note is gone); deleting after a backend restart wiped in-memory notes; entering delete flow with no outline loaded.

Related errors


AI-assisted analysis of datawhalechina/hello-agents@606a07d341 (2026-08-14). Data as JSON: /api/errors/daebf7501b33e44e. Report an issue: GitHub.