{"record":{"id":"61085d4b90cd7058","repo":"chinabugotech/hutool","slug":"failed-to-send-delete-request","errorCode":null,"errorMessage":"Failed to send DELETE request: ","messagePattern":"Failed to send DELETE request: ","errorType":"exception","errorClass":"AIException","httpStatus":null,"severity":"error","filePath":"hutool-ai/src/main/java/cn/hutool/ai/model/ollama/OllamaServiceImpl.java","lineNumber":260,"sourceCode":"\t}\n\n\t/**\n\t * 发送DELETE请求\n\t *\n\t * @param endpoint 请求端点\n\t * @param paramJson 请求参数JSON\n\t * @return 响应结果\n\t */\n\tprivate HttpResponse sendDeleteRequest(String endpoint, String paramJson) {\n\t\ttry {\n\t\t\treturn HttpRequest.delete(config.getApiUrl() + endpoint)\n\t\t\t\t.header(Header.CONTENT_TYPE, \"application/json\")\n\t\t\t\t.header(Header.ACCEPT, \"application/json\")\n\t\t\t\t.body(paramJson)\n\t\t\t\t.timeout(config.getTimeout())\n\t\t\t\t.execute();\n\t\t} catch (Exception e) {\n\t\t\tthrow new AIException(\"Failed to send DELETE request: \" + e.getMessage(), e);\n\t\t}\n\t}\n\n\t// 构建copyModel请求体\n\tprivate String buildCopyModelRequestBody(final String source, final String destination) {\n\t\tMap<String, Object> requestBody = new HashMap<>();\n\t\trequestBody.put(\"source\", source);\n\t\trequestBody.put(\"destination\", destination);\n\t\treturn JSONUtil.toJsonStr(requestBody);\n\t}\n\n}\n","sourceCodeStart":242,"sourceCodeEnd":273,"githubUrl":"https://github.com/chinabugotech/hutool/blob/8870454b2a0c29cc6ffd31dcf5667c8ceb2fc442/hutool-ai/src/main/java/cn/hutool/ai/model/ollama/OllamaServiceImpl.java#L242-L273","documentation":"Thrown by the private OllamaServiceImpl.sendDeleteRequest on a transport-level failure of HttpRequest.execute(). Used by deleteModel(modelName) (POST/DELETE to /api/delete). Like other send methods, hutool-http returns HTTP statuses rather than throwing, so a 404 (model not found) does NOT raise this -- only connection/socket/URL/SSL failures do. Cause is preserved.","triggerScenarios":"Calling ollama.deleteModel(name) when the Ollama server is not running, config.getApiUrl() is wrong (default http://localhost:11434), the host/port is unreachable, or the connection times out. A nonexistent model returns HTTP 404 via the response, not this exception.","commonSituations":"Ollama not started locally; wrong host/port (custom Ollama bind); firewall blocking localhost port; Docker container Ollama not exposed; apiUrl typo; remote Ollama unreachable.","solutions":["Ensure the Ollama daemon is running and listening on config.getApiUrl() (default http://localhost:11434).","Verify the port is reachable (curl http://localhost:11434/api/tags).","If Ollama is in Docker, publish the port (-p 11434:11434).","Inspect ex.getCause() for the real ConnectException/SocketTimeoutException.","For 'model not found', check the returned HttpResponse status instead of expecting this exception."],"exampleFix":"// before\nAIConfig cfg = new AIConfigBuilder(ModelName.OLLAMA.getValue()).build();\nollama.deleteModel(\"llama3\"); // Ollama not running -> Failed to send DELETE request\n\n// after\nAIConfig cfg = new AIConfigBuilder(ModelName.OLLAMA.getValue())\n    .setApiUrl(\"http://localhost:11434\")\n    .setTimeout(10_000)\n    .build();\nHttpResponse r = ...; // verify /api/tags reachable first\nollama.deleteModel(\"llama3\");","handlingStrategy":"validation","validationCode":"// Verify Ollama is up before calling deleteModel\nString base = config.getApiUrl(); // expect http://localhost:11434\ntry (java.net.Socket s = new java.net.Socket()) {\n    java.net.URL u = new java.net.URL(base);\n    s.connect(new java.net.InetSocketAddress(u.getHost(), u.getPort() < 0 ? 80 : u.getPort()), 2000);\n} catch (Exception ex) {\n    throw new IllegalStateException(\"Ollama unreachable at \" + base, ex);\n}","typeGuard":null,"tryCatchPattern":"try {\n    return ollama.deleteModel(name);\n} catch (AIException e) {\n    if (e.getMessage().startsWith(\"Failed to send DELETE request\")) {\n        Throwable root = e.getCause(); // ConnectException if not running\n        // ensure Ollama started; model-not-found returns HTTP 404, not this\n    }\n    throw e;\n}","preventionTips":["Start the Ollama daemon and confirm the port is published/exposed.","Set apiUrl explicitly (default is localhost:11434).","For 'model not found', check the returned HttpResponse status instead."],"tags":["ollama","network","http","transport","local-server"],"backgroundTag":null,"analyzedSha":"8870454b2a0c29cc6ffd31dcf5667c8ceb2fc442","analyzedAt":"2026-08-14T04:01:12.892Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}