Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error. mssql: Execution failed: Length cannot be less than zero. #1025

Closed
iPlotnick opened this issue Nov 13, 2017 · 12 comments
Closed

Error. mssql: Execution failed: Length cannot be less than zero. #1025

iPlotnick opened this issue Nov 13, 2017 · 12 comments
Labels

Comments

@iPlotnick
Copy link

  • MSSQL Extension Version: 1.2.1
  • VSCode Version: 1.18.0
  • OS Version: Windows 7 x64

Steps to Reproduce:

  1. Start new workspace.
  2. Add two folders.
  3. Open SQL file (with SQL commands).
  4. Press Ctrl + Shift + E. No reaction.
  5. Press F7 (bonded early). See error.

Run from folder (not from workspace) works as usual.

@kevcunnane
Copy link
Contributor

@MattIrv could you take a look at this issue? Does it reproduce for you?

@MattIrv
Copy link
Contributor

MattIrv commented Nov 13, 2017

@4174 Thanks for reporting this. I can't seem to reproduce it, so if you're still getting this error message, could you please let me know the answers to the following questions so I can continue trying to track it down:

  • Does this error happen for all SQL files or just for a particular one? Are you testing both from the folder and workspace with the same query? If it happens for some queries and not others, is there any chance you could post a simple query that causes it to happen?
  • When you say "Open SQL file" in step 3, are you creating a new untitled file from scratch (ctrl+n), or are you opening a saved file somewhere on disk? If it's a saved file, am I understanding correctly that the file is saved outside of either of the two folders you opened?
  • In step 5 what command do you have F7 mapped to?

Edit: Additionally, when you're attempting to execute using ctrl+shift+e, have you already established a connection for the query?

Thanks!

@iPlotnick
Copy link
Author

@MattIrv Thank You for answer

It's seems that problem is folder I run script from. If it's local folder then no problem, but problem arises when i open file from network share.

@iPlotnick
Copy link
Author

Installed update 1.18.1 doesn't resolve error.

@MattIrv
Copy link
Contributor

MattIrv commented Nov 18, 2017

@4174 thanks for the additional details. I can reproduce this issue, but only when a backslash character \ is somewhere in the path to the file (either in the filename itself or in the name of one of the parent directories). I'm not sure what's causing this bug yet, but I'll keep looking into it.

Are there any backslashes or other characters that Windows might not expect (potentially any of :, *, ?, <, >, or |) somewhere in the full path of the file that gives you this error?

@MattIrv MattIrv self-assigned this Nov 18, 2017
@MattIrv
Copy link
Contributor

MattIrv commented Nov 18, 2017

Stack trace


    Unknown error System.ArgumentOutOfRangeException: Length cannot be less than zero.
    Parameter name: length
       at System.String.Substring(Int32 startIndex, Int32 length)
       at System.Uri.CreateHostStringHelper(String str, UInt16 idx, UInt16 end, Flags& flags, String& scopeId)
       at System.Uri.CreateHostString()
       at System.Uri.EnsureHostString(Boolean allowDnsOptimization)
       at System.Uri.ReCreateParts(UriComponents parts, UInt16 nonCanonical, UriFormat formatAs)
       at System.Uri.GetUnescapedParts(UriComponents uriParts, UriFormat formatAs)
       at System.Uri.GetLocalPath()
       at System.Uri.get_LocalPath()
       at Microsoft.SqlTools.ServiceLayer.Workspace.Workspace.ResolveFilePath(String filePath) in C:\J\jobs\sqltoolsservice_master_win\workspace\src\Microsoft.SqlTools.ServiceLayer\Workspace\Workspace.cs:line 138
       at Microsoft.SqlTools.ServiceLayer.Workspace.Workspace.GetFileBuffer(String filePath, String initialBuffer) in C:\J\jobs\sqltoolsservice_master_win\workspace\src\Microsoft.SqlTools.ServiceLayer\Workspace\Workspace.cs:line 200
       at Microsoft.SqlTools.ServiceLayer.Workspace.WorkspaceService`1.<HandleDidOpenTextDocumentNotification>d__38.MoveNext() in C:\J\jobs\sqltoolsservice_master_win\workspace\src\Microsoft.SqlTools.ServiceLayer\Workspace\WorkspaceService.cs:line 258

@iPlotnick
Copy link
Author

@MattIrv Thank You for answer.

Really a problem in the so-called administrative directory, rather than in the workspace.
In the name of the administrative directory is really the sign of "$".
Starting from the workspace from a non-administrative directory is successful.

@MattIrv
Copy link
Contributor

MattIrv commented Nov 21, 2017

Thanks. I'm looking into a fix for this issue and should be able to get one out soon. @4174 can you clarify whether you're seeing this for a mapped network drive (e.g. z:\some_directory$\some_file.sql) or when just using an unmounted network path (e.g. \\some_server\some_directory$\some_file.sql), or both?

So far I've only seen this issue when using a mapped drive. If that's the case, using the corresponding unmounted network path should be a good workaround.

@iPlotnick
Copy link
Author

@MattIrv Thank You for answer.

Your assumption is correct, I run scripts from the unmounted network path without problems.

Thank You

@MattIrv
Copy link
Contributor

MattIrv commented Dec 11, 2017

Thanks again for your help tracking this down. We've just released version 1.3.0 of the extension, which includes the fix for this bug. I'll close this issue now, but if you're still having problems with it after updating feel free to reopen this.

@MattIrv MattIrv closed this as completed Dec 11, 2017
@iPlotnick
Copy link
Author

@MattIrv Thank You, I tested the new version and it works like a charm.

@ivanmem
Copy link

ivanmem commented Apr 28, 2019

MySQL with the Pomelo.EntityFrameworkCore.MySql driver is an issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants