leona / helix-gpt

Code assistant language server for Helix with support for Copilot/OpenAI/Codeium/Ollama
MIT License
403 stars 27 forks source link

[BUG] Getting "unknown Editor-Version header for IDE auth" #73

Open marcinkoziej opened 2 days ago

marcinkoziej commented 2 days ago

helix-editor version 24.3

helix-gpt version Exact version of Helix GPT. commit 2a047347968e (newer then 0.34)

Describe the bug When trying to run code actions against copilot, I get Fetch failed with status 400 body bad request: unknown Editor-Version header for IDE auth.

APP 2024-11-03T20:55:33.082Z --> copilot | chat request | ["Add documentation to this code.","\nfn sum(a: i32, b: i32) {\n    a + b;\n}","file:///home/marcin/Projects/i_am_here/src/main.rs","rust"]

APP 2024-11-03T20:55:33.082Z --> fetch | /chat/completions

APP 2024-11-03T20:55:33.236Z --> chat failed | Fetch failed with status 400 body bad request: unknown Editor-Version header for IDE auth
 url: /chat/completions

APP 2024-11-03T20:55:33.236Z --> sending diagnostics | [{"message":"Fetch failed with status 400 body bad request: unknown Editor-Version header for IDE auth\n url: /chat/completions","severity":1,"range":{"end":{"character":0,"line":36},"start":{"character":0,"line":32}}}]

APP 2024-11-03T20:55:33.236Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/marcin/Projects/i_am_here/src/main.rs","diagnostics":[{"message":"Fetch failed with status 400 body bad request: unknown Editor-Version header for IDE auth\n url: /chat/completions","severity":1,"range":{"end":{"character":0,"line":36},"start":{"character":0,"line":32}},"source":"helix-gpt"}]}}

What's interesting, is that hints do work! Log:

APP 2024-11-03T20:55:05.707Z --> sent request | {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///home/marcin/Projects/i_am_here/src/main.rs","diagnostics":[{"message":"Fetching completion...","severity":3,"range":{"start":{"line":34,"character":0},"end":{"line":35,"character":0}},"source":"helix-gpt"}]}}

APP 2024-11-03T20:55:05.707Z --> copilot | completion request

APP 2024-11-03T20:55:05.707Z --> fetch | /v1/engines/copilot-codex/completions

APP 2024-11-03T20:55:05.996Z --> response | https://copilot-proxy.githubusercontent.com/v1/engines/copilot-codex/completions | 200

APP 2024-11-03T20:55:05.997Z --> completion hints: | 
    let result = a + b;
    println!("Result: {}", result);
}
,
    a + b;
}
,
    let sum = a + b;
    println!("Sum of {} and {} is {}", a, b, sum);
}

helix-gpt logs Pasted relevant logs above

marcinkoziej commented 2 days ago

Lying that editor is VSCode fixes the issue for me. Did Micro$oft start to block 3rd party editors?

diff --git a/src/providers/github.ts b/src/providers/github.ts
index a8e05fa..d6de673 100644
--- a/src/providers/github.ts
+++ b/src/providers/github.ts
@@ -98,8 +98,8 @@ export default class Github extends ApiBase {
       "Content-Type": "application/json; charset=utf-8",
       "User-Agent": "helix/1.0.0",
       "Authorization": `Bearer ${this.copilotSession?.raw}`,
-      "Editor-Plugin-Version": "helix-gpt/1.0.0",
-      "Editor-Version": "helix/1.0.0",
+      "Editor-Plugin-Version": "vscode/1.95.0",
+      "Editor-Version": "vscode/1.95.0",
       "Openai-Intent": "conversation-panel",
       "Openai-Organization": "github-copilot",
       "VScode-MachineId": genHexStr(64),