question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

LSP: Request textDocument/codeAction failed. Invalid file path

See original GitHub issue

Describe the bug This just came up, have never seen it before. Whenever I type something in a specific dart file VSCode’s Output panel opens up with an error message along with a notification about it. The message is as follows:

[Error - 20:39:21] Request textDocument/codeAction failed.
  Message: Invalid file path
  Code: -32003 
c:\Users\myuser\dev\project\lib\core\widgets\sidebar.dart

As I said, it only happens within this one specific file. No other files. It actually happens when clicking around in the file too. I’ve tried reloading the window, restarting VSCode, disabling and reenabling the Dart extension, disabling the Vim extension. Removing the file and recreating it pasting the stuff I previously had present in the file. Nothing works at this point. As I also said, this just started happening, and I have never seen it before. Nor do I have any idea on my own what I could have done to cause anything.

To Reproduce I really don’t know how to reproduce, to be honest…

Hmm… So while writing I started fiddling around a little bit. Started by removing everything in the file I had problems with and retyped it from a copy in Notepad. ~As soon as I came to adding the square brackets to this line~ I had actually typed out all the other stuff, since I used the tools present in VSCode to generate most of it:

static final List<String> _items = [];

It started freaking out. The type doesn’t seem to matter. I think it’s the combination of static, final, and the list square brackets OR curly braces, instead of square brackets. Also, the underscore does not matter, just so you know.

Also, to add for clarification: This works without errors:

static final String _string = "dwadnwaj";

// this too, although it doesn't compile of course
static final List<String> _grndjkgr = "adsnfshjfs";

The snippets above should be surrounded by the other content of the file in the steps below. Otherwise I cannot reproduce.

I’m gonna give my computer a restart a try. I’ll report back if anything changes.

  1. Create a file from root flutter project, lib/core/widgets/sidebar.dart, with the following contents:
  2. Add the following contents to the file:
    import 'package:flutter/widgets.dart';
    
    /// This widget is a reimplementatino of the [Drawer] widget with the added
    ///  ability to act as a collapsable sidebar on desktop sized screens.
    class Sidebar extends StatelessWidget {
      static final List<Widget> _items = [
        _SidebarItem(),
      ];
    
      final bool expanded;
    
      const Sidebar({
        Key key,
        this.expanded = false,
      }) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
        return LayoutBuilder(
          builder: (context, constraints) => ListView.builder(
            scrollDirection: Axis.vertical,
            itemCount: _items.length,
            itemBuilder: (context, index) => _items[index],
          ),
        );
      }
    }
    
    // class _SidebarItem {}
    

Sad truth is that I can’t reproduce the narrowed problem in any other file. Just the sidebar.dart one.

I have a really hard time believing anyone else will be able to reproduce, it feels like it has to do something with my exact setup. But I guess we’ll find out.

English is not my native language.

I’ll be here for questions if anyone has them.

Thanks for everyone’s time!

Expected behavior No errors should be thrown.

Versions (please complete the following information):

  • VS Code version: 1.52.1 (user setup)
  • Dart extension version: v3.18.1 (LSP enabled)
  • Dart/Flutter SDK version: Dart 2.12.0 (build 2.12.0-133.2.beta) / Flutter 1.25.0-8.2.pre • channel beta
  • OS: Windows 10 2004 (since it might have to do with file paths?)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:10
  • Comments:51 (22 by maintainers)

github_iconTop GitHub Comments

22reactions
fryettecommented, Feb 16, 2021

Probably someone has workarounds? Have the same error

20reactions
theflutterfactorycommented, Jul 21, 2021

You don’t need to restart the entire system. just restart VS code

Read more comments on GitHub >

github_iconTop Results From Across the Web

flutter - viewing .pub-cache files gives Request textDocument ...
Any ideas on how to fix? I have tried changing the settings.json dart sdk setting from null to my dart sdk location: "dart.sdkPath":...
Read more >
LSP: Request textDocument/codeAction failed. Invalid file path
Describe the bug. This just came up, have never seen it before. Whenever I type something in a specific dart file VSCode's Output...
Read more >
Language Server Extension Guide - Visual Studio Code
This guide will teach you how to build a Language Client / Server using our Node SDK. The remaining document assumes that you...
Read more >
Language Server Protocol Specification - 3.15
This document describes the 3.15.x version of the language server protocol. ... Capabilities specific to the `textDocument/codeAction` request.
Read more >
calva 2022-09-16 - Slack Archive
LSP server info at final test showing: • clojure-lsp path configured: ... See error pop up: Request textDocument/codeAction failed.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found