tidev / vscode-titanium

Titanium SDK development tools and UI package for Visual Studio Code.
Apache License 2.0
38 stars 19 forks source link

Validate sdkVersion returned in generateCompletions #79

Closed jasonkneen closed 5 years ago

jasonkneen commented 5 years ago

Describe the Bug

Get the following error when launching a workspace with the extension installed:

"Error generating autocomplete suggestions. The "path" argument must be of type string. Received type object"

Steps to reproduce the Bug

Steps to reproduce the behavior, e.g.:

  1. Open VSCode
  2. Search for Extension
  3. Install
  4. Reload
  5. Error is shown after extension checks environment
  6. Autocomplete no longer works

Screenshot of error

https://cl.ly/a4fc866015b4

Managed to get log output:

vscode-customcss is active!
[vscode-icons] v8.6.0 activated!
[eg2.tslint] Accessing a window scoped configuration for a resource is not expected. To associate 'tslint.jsEnable' to a resource, define its scope to 'resource' in configuration contributions in 'package.json'.
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type object
    at assertPath (path.js:39:11)
    at Object.join (path.js:1157:7)
    at Object.getSDKCompletionsFileName (/Users/jkneen/Documents/Appcelerator_Studio_Workspace/vscode-appcelerator-titanium/out/providers/completion/completionItemProviderHelper.js:59:17)
    at Object.<anonymous> (/Users/jkneen/Documents/Appcelerator_Studio_Workspace/vscode-appcelerator-titanium/out/providers/completion/completionItemProviderHelper.js:202:45)
    at Generator.next (<anonymous>)
    at __awaiter (/Users/jkneen/Documents/Appcelerator_Studio_Workspace/vscode-appcelerator-titanium/out/providers/completion/completionItemProviderHelper.js:7:71)
    at new Promise (<anonymous>)
    at __awaiter (/Users/jkneen/Documents/Appcelerator_Studio_Workspace/vscode-appcelerator-titanium/out/providers/completion/completionItemProviderHelper.js:3:12)
    at Object.generateSDKCompletions (/Users/jkneen/Documents/Appcelerator_Studio_Workspace/vscode-appcelerator-titanium/out/providers/completion/completionItemProviderHelper.js:200:12)
    at /Users/jkneen/Documents/Appcelerator_Studio_Workspace/vscode-appcelerator-titanium/out/extension.js:204:46
    at Generator.next (<anonymous>)
    at __awaiter (/Users/jkneen/Documents/Appcelerator_Studio_Workspace/vscode-appcelerator-titanium/out/extension.js:7:71)
    at new Promise (<anonymous>)
    at __awaiter (/Users/jkneen/Documents/Appcelerator_Studio_Workspace/vscode-appcelerator-titanium/out/extension.js:3:12)
    at generateCompletions (/Users/jkneen/Documents/Appcelerator_Studio_Workspace/vscode-appcelerator-titanium/out/extension.js:195:12)
    at vscode.window.withProgress.appc_1.default.getInfo.error (/Users/jkneen/Documents/Appcelerator_Studio_Workspace/vscode-appcelerator-titanium/out/extension.js:153:29)
    at ChildProcess.getInfo.proc.on (/Users/jkneen/Documents/Appcelerator_Studio_Workspace/vscode-appcelerator-titanium/out/appc.js:44:28)
    at ChildProcess.emit (events.js:182:13)
    at maybeClose (internal/child_process.js:961:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
jasonkneen commented 5 years ago

Looking at the code in debug mode, I was able to find the function that's failing and wrote out the version variable which was coming back as:

_:"6.1.2.GA"
$:Object
platform:"android"

Changed the function (for testing) to:

function getSDKCompletionsFileName(version) {
    console.error(version)
    return "/users/jkneen/.titanium/completions/titanium/8.0.0.GA/completions.json"
 //return path.join(os_1.homedir().toString(), '.titanium', 'completions', 'titanium', version, 'completions.json');
}

and works fine so not sure where 6.1.2.GA is coming from

ewanharris commented 5 years ago

The variable that node appears to be throwing on is declared here. Which should just be pulling the sdk-version tag from the tiapp here. Maybe the formatting of that is bad?

ewanharris commented 5 years ago

Yeah I think it's down to that, I can get the same error when my sdk-version is set like so <sdk-version platform="android">8.0.0.GA</sdk-version>, the inspector seems to match what you pasted above too

jasonkneen commented 5 years ago

Ahhh -- dammit -- got it -- stupid TiApp.xml has TWO sdk-version tags and one is for Android -- they've used the platform= attribute but that doesn't work for this tag so it's picking up the second one which is ANDROID and 6.1.2!

<sdk-version platform="android">6.1.2.GA</sdk-version>
<sdk-version platform="iPhone">7.5.1.GA</sdk-version>

doh!

ewanharris commented 5 years ago

That's a new one to me 😆, I'll reopen this though so we can improve the validation and error reporting rather than having node throw this

jasonkneen commented 5 years ago

👍