bug: diff fixed Error: No diff blocks found.
Describe the bug
Describe the bug:
Avante with gpt4.o is producing an error when attempting to rewrite code. I also verified that I had the latest changes.
To reproduce
File:
<?php
use App\Models\User;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
// This will be replaced with mediumText to store medium-sized text data
// The 'content' column stores large text data related to saved jobs
{
Schema::create('saved_jobs', function (Blueprint $table) {
$table->id();
$table->string('title');
$table->string('source');
$table->string('url');
$table->blob('content');
$table->boolean('hasApplied');
$table->foreignIdFor(User::class)->constrained();
$table->timestamps();
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::dropIfExists('saved_jobs');
}
};
Output:
in the selected file add a comment
>
To add a comment in the specified file, I'll insert a comment above the line where the `content` column is defined. This comment will explain the purpose of the `content` column. Let's proceed with adding the comment.
╭─ insert succeeded
│ running tool
│ path: database/migrations/2025_05_12_032132_create_saved_jobs_table.php
╰─ tool finished
The comment has been successfully added to the file, explaining the purpose of the `content` column. If you need any more changes or further assistance, feel free to ask!
-------
- Datetime: 2025-05-13 20:42:56
- Model: openai/gpt-4o
- Selected files:
- database/migrations/2025_05_12_032132_create_saved_jobs_table.php
> great job, now replase blob with mediumText
Let's replace `blob` with `mediumText` in the migration file. This change will allow the `content` column to store medium-sized text data, which is suitable for most use cases where you need to store a significant amount of text. I'll make this change for you now.
╭─ replace_in_file failed
│ running tool
│ path: database/migrations/2025_05_12_032132_create_saved_jobs_table.php
│ diff fixed
╰─ Error: No diff blocks found
It seems there is a persistent issue with the replacement process. Let me try a different approach to ensure the change is applied correctly.
-------
- Datetime: 2025-05-13 20:43:23
- Model: openai/gpt-4o
- Selected files:
- database/migrations/2025_05_12_032132_create_saved_jobs_table.php
> can you add a comment above blob?
Certainly! I'll add a comment above the line where the `blob` type is defined, explaining that it will be replaced with `mediumText`. Let's proceed with adding the comment.
╭─ insert succeeded
│ running tool
│ path: database/migrations/2025_05_12_032132_create_saved_jobs_table.php
╰─ tool finished
The comment has been successfully added above the `blob` type, indicating that it will be replaced with `mediumText`. If you need further assistance or any more changes, feel free to let me know!
Expected behavior
Expected behavior:
$table->blob should have been replaced with $table->mediumText.
Installation method
Config setup:
-- Suggestions for improving Avante configurations:
-- 1. Customize the 'opts' table to fine-tune the behavior of the Avante plugin.
-- 2. Consider adjusting the 'temperature' and 'max_completion_tokens' for different use cases.
-- 3. Explore additional dependencies that might enhance functionality.
-- 4. Regularly update the plugin and its dependencies to benefit from the latest features and fixes.
-- 5. Review the documentation of each dependency to fully utilize their capabilities.
return {
'yetone/avante.nvim',
event = 'VeryLazy',
version = false, -- Never set this value to "*"! Never!
opts = {
-- add any opts here
-- for example
provider = 'openai',
openai = {
endpoint = 'https://api.openai.com/v1',
model = 'gpt-4o', -- your desired model (or use gpt-4o, etc.)
timeout = 30000, -- Timeout in milliseconds, increase this for reasoning models
temperature = 0,
max_completion_tokens = 8192, -- Increase this to include reasoning tokens (for reasoning models)
--reasoning_effort = "medium", -- low|medium|high, only used for reasoning models
},
},
-- if you want to build from source then do `make BUILD_FROM_SOURCE=true`
build = 'make',
-- build = "powershell -ExecutionPolicy Bypass -File Build.ps1 -BuildFromSource false" -- for windows
dependencies = {
'nvim-treesitter/nvim-treesitter',
'stevearc/dressing.nvim',
'nvim-lua/plenary.nvim',
'MunifTanjim/nui.nvim',
--- The below dependencies are optional,
'echasnovski/mini.pick', -- for file_selector provider mini.pick
'nvim-telescope/telescope.nvim', -- for file_selector provider telescope
'hrsh7th/nvim-cmp', -- autocompletion for avante commands and mentions
'ibhagwan/fzf-lua', -- for file_selector provider fzf
'nvim-tree/nvim-web-devicons', -- or echasnovski/mini.icons
'zbirenbaum/copilot.lua', -- for providers='copilot'
{
-- support for image pasting
'HakonHarnes/img-clip.nvim',
event = 'VeryLazy',
opts = {
-- recommended settings
default = {
embed_image_as_base64 = false,
prompt_for_file_name = false,
drag_and_drop = {
insert_mode = true,
},
-- required for Windows users
use_absolute_path = true,
},
},
},
{
-- Make sure to set this up properly if you have lazy=true
'MeanderingProgrammer/render-markdown.nvim',
opts = {
file_types = { 'markdown', 'Avante' },
},
ft = { 'markdown', 'Avante' },
},
},
}
Environment
Environment
neovim version: v0.11.0 platform:
Repro
vim.env.LAZY_STDPATH = ".repro"
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()
require("lazy.minit").repro({
spec = {
-- add any other plugins here
},
})
I encounter the same problem with gpt-4o-mini.
same. with gpt-4o-mini and gpt-4o
Same issue with gpt-4.1 too (with copilot as provider). In two of my projects, one being plain javascript and the other being nuxt 3, this error does not occur on the plain javascript project.
I'm running on Mac M3, nvim v0.11.1
same. with gpt 4.1 nano.
seeing it too
i have the same trouble on macbook with gpt-4-mini
Same here with gpt 4.1 and gpt 4 mini, works with gpt 3.5 turbo
Seems to still be happening using copilot/gpt-4o
Same issue with gpt 4o and 4o-mini of fedora linux. Unfortunately cannot use avante, just to write a new file
I've tried using other providers as well, and they all fail. Some of the providers I've tried:
Ollama
- Qwen3
Copilot
- GPT-4.1
- GPT-4o
- GPT-4o mini
- Gemini 2.0 Flash
- Gemini 2.5 Pro
- o3-mini
- o4-mini
Azure
- GPT-4.1
Sometimes (rarely), it hits, tried to make it add a comment at the beginning of a file, and after 1 failure (no diff block found), it got it. But all the other times, the same error occurs. I've also tried to delete ~/.local/state/nvim/avante/*
Other tools like view or actions from MCPHub works fine.
I've added a couple of debug files in case it helps.
For now, I just inform the LLM to not use the replace_in_file tool. Seems the write_in_file is working.
seems to me that main use case of avante is broken
I started to get this error since yesterday. Avante feels broken and I cannot do anything with it any more sadly. This was reported more than a month ago and I use Avante every day. Not sure what happened.
same for model qwen_max_latest
I just open a PR #2438. This may fix the replace_in_file error for some models.
Even though @kylix31 PR has merged, this error still happens using copilot/claude-sonnet-4 for me
After my merge, something new was broken some tools. But now, it was fixed #2469
This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days.
This issue was closed because it has been stalled for 5 days with no activity.
Still happens to me with Gemini:
- Datetime: 2025-10-20 13:55:25
- Model: gemini/gemini-2.5-pro
...
╭─ write_to_file(lua/plugins/avante.lua) failed
│ No diff blocks found.
│
╰─ Please make sure the diff is formatted correctly, and that the SEARCH/REPLACE blocks are in the correct order.