I get "Failed to get response: 100" error whenever i try to use 'CopilotChatExplain' with a selection. The weird part is that i can see the response but it prints a really long error message at the end. I made little patch to ignore the err if the response.status is 100 and it doesn't have any issues but it would be better if someone who is more knowledgeable can look at it (i don't know the context of this code so i am not sure if ignoring is the right way). I don't know why but the err variable is same with the response.body and those are all finish with the '"choices":[{"finish_reason":"stop","index":0,"delta":{"content":null}}]" so i am guessing there shouldn't be any problem?. This is the start of the response i get:
This Python script demonstrates how to use Redis as a distributed lock mechanism, which is useful for synchronizing access to shared resources across multiple processes or machines. The script uses the redis-py library to connect to a local Redis instance and create a lock object.
At the start, the script defines the Redis connection URL and creates a Redis client using redis.utils.from_url. It then initializes a lock named "REDIS_LOCK:DENEMEDENEME" with several parameters: sleep (how long to wait between lock acquisition attempts), blocking (whether to wait for the lock if it's not immediately available), blocking_timeout (maximum time to wait for the lock), and thread_local (ensuring the lock is thread-local).
The main logic is a loop that runs ten times. In each iteration, it uses a with statement to acquire the lock. This ensures that only one process or thread can execute the critical section at a time. Inside the locked section, it prints a message, increments a counter, and sleeps for one second to simulate work. After releasing the lock, it waits another second before the next iteration.
A key implementation detail is the use of the with statement, which guarantees that the lock is properly released even if an exception occurs. The blocking and blocking_timeout parameters help prevent deadlocks by limiting how long the script waits for the lock. This pattern is common in distributed systems to ensure safe, exclusive access to shared resources. Performance-wise, the sleep and blocking_timeout values should be tuned based on the expected workload and contention to avoid unnecessary delays.
Failed to get response: 100
data: {"choices":[{"index":0,"delta":{"content":"","role":"assistant"}}],"created":1767708498,"id":"chatcmpl-Cv21KAFOw3jFbNlazEXqm9BJkwDKG","model":"gpt-4.1-2025-04-14","system_fingerprint":"fp_1a2c4a5ede"}
data: {"choices":[{"index":0,"delta":{"content":"This"}}],"created":1767708498,"id":"chatcmpl-Cv21KAFOw3jFbNlazEXqm9BJkwDKG","model":"gpt-4.1-2025-04-14","system_fingerprint":"fp_1a2c4a5ede"}
data: {"choices":[{"index":0,"delta":{"content":" Python"}}],"created":1767708498,"id":"chatcmpl-Cv21KAFOw3jFbNlazEXqm9BJkwDKG","model":"gpt-4.1-2025-04-14","system_fingerprint":"fp_1a2c4a5ede"}
data: {"choices":[{"index":0,"delta":{"content":" script"}}],"created":1767708498,"id":"chatcmpl-Cv21KAFOw3jFbNlazEXqm9BJkwDKG","model":"gpt-4.1-2025-04-14","system_fingerprint":"fp_1a2c4a5ede"}
data: {"choices":[{"index":0,"delta":{"content":" demonstrates"}}],"created":1767708498,"id":"chatcmpl-Cv21KAFOw3jFbNlazEXqm9BJkwDKG","model":"gpt-4.1-2025-04-14","system_fingerprint":"fp_1a2c4a5ede"}
data: {"choices":[{"index":0,"delta":{"content":" how"}}],"created":1767708498,"id":"chatcmpl-Cv21KAFOw3jFbNlazEXqm9BJkwDKG","model":"gpt-4.1-2025-04-14","system_fingerprint":"fp_1a2c4a5ede"}
data: {"choices":[{"index":0,"delta":{"content":" to"}}],"created":1767708498,"id":"chatcmpl-Cv21KAFOw3jFbNlazEXqm9BJkwDKG","model":"gpt-4.1-2025-04-14","system_fingerprint":"fp_1a2c4a5ede"}
data: {"choices":[{"index":0,"delta":{"content":" use"}}],"created":1767708498,"id":"chatcmpl-Cv21KAFOw3jFbNlazEXqm9BJkwDKG","model":"gpt-4.1-2025-04-14","system_fingerprint":"fp_1a2c4a5ede"}
data: {"choices":[{"index":0,"delta":{"content":" Redis"}}],"created":1767708498,"id":"chatcmpl-Cv21KAFOw3jFbNlazEXqm9BJkwDKG","model":"gpt-4.1-2025-04-14","system_fingerprint":"fp_1a2c4a5ede"}
data: {"choices":[{"index":0,"delta":{"content":" as"}}],"created":1767708498,"id":"chatcmpl-Cv21KAFOw3jFbNlazEXqm9BJkwDKG","model":"gpt-4.1-2025-04-14","system_fingerprint":"fp_1a2c4a5ede"}
data: {"choices":[{"index":0,"delta":{"content":" a"}}],"created":1767708498,"id":"chatcmpl-Cv21KAFOw3jFbNlazEXqm9BJkwDKG","model":"gpt-4.1-2025-04-14","system_fingerprint":"fp_1a2c4a5ede"}
data: {"choices":[{"index":0,"delta":{"content":" distributed"}}],"created":1767708498,"id":"chatcmpl-Cv21KAFOw3jFbNlazEXqm9BJkwDKG","model":"gpt-4.1-2025-04-14","system_fingerprint":"fp_1a2c4a5ede"}
data: {"choices":[{"index":0,"delta":{"content":" lock"}}],"created":1767708498,"id":"chatcmpl-Cv21KAFOw3jFbNlazEXqm9BJkwDKG","model":"gpt-4.1-2025-04-14","system_fingerprint":"fp_1a2c4a5ede"}
data: {"choices":[{"index":0,"delta":{"content":" mechanism"}}],"created":1767708498,"id":"chatcmpl-Cv21KAFOw3jFbNlazEXqm9BJkwDKG","model":"gpt-4.1-2025-04-14","system_fingerprint":"fp_1a2c4a5ede"}
data: {"choices":[{"index":0,"delta":{"content":","}}],"created":1767708498,"id":"chatcmpl-Cv21KAFOw3jFbNlazEXqm9BJkwDKG","model":"gpt-4.1-2025-04-14","system_fingerprint":"fp_1a2c4a5ede"}
data: {"choices":[{"index":0,"delta":{"content":" which"}}],"created":1767708498,"id":"chatcmpl-Cv21KAFOw3jFbNlazEXqm9BJkwDKG","model":"gpt-4.1-2025-04-14","system_fingerprint":"fp_1a2c4a5ede"}
data: {"choices":[{"index":0,"delta":{"content":" is"}}],"created":1767708498,"id":"chatcmpl-Cv21KAFOw3jFbNlazEXqm9BJkwDKG","model":"gpt-4.1-2025-04-14","system_fingerprint":"fp_1a2c4a5ede"}
data: {"choices":[{"index":0,"delta":{"content":" useful"}}],"created":1767708498,"id":"chatcmpl-Cv21KAFOw3jFbNlazEXqm9BJkwDKG","model":"gpt-4.1-2025-04-14","system_fingerprint":"fp_1a2c4a5ede"}
data: {"choices":[{"index":0,"delta":{"content":" for"}}],"created":1767708498,"id":"chatcmpl-Cv21KAFOw3jFbNlazEXqm9BJkwDKG","model":"gpt-4.1-2025-04-14","system_fingerprint":"fp_1a2c4a5ede"}
diff --git a/lua/CopilotChat/client.lua b/lua/CopilotChat/client.lua
index 93e1c91..df7f2e6 100644
--- a/lua/CopilotChat/client.lua
+++ b/lua/CopilotChat/client.lua
@@ -533,7 +533,7 @@ function Client:ask(opts)
self.current_job = nil
end
- if err then
+ if err and response.status ~= 100 then
local error_msg = 'Failed to get response: ' .. err
if response then
Hello,
I get "Failed to get response: 100" error whenever i try to use 'CopilotChatExplain' with a selection. The weird part is that i can see the response but it prints a really long error message at the end. I made little patch to ignore the err if the response.status is 100 and it doesn't have any issues but it would be better if someone who is more knowledgeable can look at it (i don't know the context of this code so i am not sure if ignoring is the right way). I don't know why but the err variable is same with the response.body and those are all finish with the '"choices":[{"finish_reason":"stop","index":0,"delta":{"content":null}}]" so i am guessing there shouldn't be any problem?. This is the start of the response i get:
This Python script demonstrates how to use Redis as a distributed lock mechanism, which is useful for synchronizing access to shared resources across multiple processes or machines. The script uses the redis-py library to connect to a local Redis instance and create a lock object.
At the start, the script defines the Redis connection URL and creates a Redis client using redis.utils.from_url. It then initializes a lock named "REDIS_LOCK:DENEMEDENEME" with several parameters: sleep (how long to wait between lock acquisition attempts), blocking (whether to wait for the lock if it's not immediately available), blocking_timeout (maximum time to wait for the lock), and thread_local (ensuring the lock is thread-local).
The main logic is a loop that runs ten times. In each iteration, it uses a with statement to acquire the lock. This ensures that only one process or thread can execute the critical section at a time. Inside the locked section, it prints a message, increments a counter, and sleeps for one second to simulate work. After releasing the lock, it waits another second before the next iteration.
A key implementation detail is the use of the with statement, which guarantees that the lock is properly released even if an exception occurs. The blocking and blocking_timeout parameters help prevent deadlocks by limiting how long the script waits for the lock. This pattern is common in distributed systems to ensure safe, exclusive access to shared resources. Performance-wise, the sleep and blocking_timeout values should be tuned based on the expected workload and contention to avoid unnecessary delays.
This is the current workaround i use to ignore it if someone wonders: