neowit / vim-force.com

Vim plugin for force.com
113 stars 25 forks source link

Unable to refresh projects and files (Unexpected end-of-input) #90

Open ldebruyn opened 7 years ago

ldebruyn commented 7 years ago

I cannot ApexRefreshProject or ApexRefreshFile today. I tried it on two different projects, including trying to pull down into an empty folder. I get an error about:

[ERROR] spray.json.JsonParser$ParsingException: Unexpected end-of-input at input index 0 (line 1, position 1), expected JSON Value: Attached is the full log.

log-buffer.txt

neowit commented 7 years ago

Hello @ldebruyn

You say you are trying to refresh project, but the log file you attached shows result of diff with remote operation.

If refresh still does not work please include the log as well as

ldebruyn commented 7 years ago

Apologies. I am using a small test project here, but the same problem occurs on the enormous production project. Here is a bit more information for you. Thanks for reading!

OS/version: macOS Sierra 10.12.5 (16F73)

vim version (full output): VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Jun 5 2017 16:10:15) MacOS X (unix) version Included patches: 1-617 Compiled by Homebrew Huge version without GUI. Features included (+) or not (-): +acl +file_in_path +mouse_sgr +tag_old_static +arabic +find_in_path -mouse_sysmouse -tag_any_white +autocmd +float +mouse_urxvt -tcl -balloon_eval +folding +mouse_xterm +termguicolors -browse -footer +multi_byte +terminfo ++builtin_terms +fork() +multi_lang +termresponse +byte_offset -gettext -mzscheme +textobjects +channel -hangul_input +netbeans_intg +timers +cindent +iconv +num64 +title -clientserver +insert_expand +packages -toolbar +clipboard +job +path_extra +user_commands +cmdline_compl +jumplist +perl +vertsplit +cmdline_hist +keymap +persistent_undo +virtualedit +cmdline_info +lambda +postscript +visual +comments +langmap +printer +visualextra +conceal +libcall +profile +viminfo +cryptv +linebreak +python +vreplace +cscope +lispindent -python3 +wildignore +cursorbind +listcmds +quickfix +wildmenu +cursorshape +localmap +reltime +windows +dialog_con -lua +rightleft +writebackup +diff +menu +ruby -X11 +digraphs +mksession +scrollbind -xfontset -dnd +modify_fname +signs -xim -ebcdic +mouse +smartindent -xpm +emacs_tags -mouseshape +startuptime -xsmp +eval +mouse_dec +statusline -xterm_clipboard +ex_extra -mouse_gpm -sun_workshop -xterm_save +extra_search -mouse_jsbterm +syntax
+farsi +mouse_netterm +tag_binary
system vimrc file: "$VIM/vimrc" user vimrc file: "$HOME/.vimrc" 2nd user vimrc file: "~/.vim/vimrc" user exrc file: "$HOME/.exrc" defaults file: "$VIMRUNTIME/defaults.vim" fall-back for $VIM: "/usr/local/share/vim" Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H -DMACOS_X_UNIX -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
Linking: clang -L. -L/usr/local/lib -L/usr/local/lib -o vim -lm -lncurses -liconv -framework Cocoa -fstack-protector -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl -framework Python -lruby.2.0.0 -lobjc

I opened up the project, and ran the other commands. Here are the results:

output of :ApexToolingVersion in vim: --action=version --tempFolderPath='/Users/leodebruyn/code/apex-temp' --config='/Users/leodebruyn/code/apex-properties/lionbrave-developer.properties' --projectPath='/Users/leodebruyn/code/lionbrave-developer' --debuggingHeaderConfig='/var/folders/_n/xzft2wm167ggpsytcwr5028m0000gn/T/vlRcO5E/3-apexTraceFlag.conf' --responseFilePath='/Users/leodebruyn/code/lionbrave-developer/.vim-force.com/response_version' --pollWaitMillis=1000 --maxPollRequests=1000 Trying to start server using command: java -Dorg.apache.commons.logging.simplelog.showlogname=false -Dorg.apache.commons.logging.simplelog.showShortLogname=false -Dorg.apache.commons.logging.simplelog.defaultlog=info -Dfile.encoding=UTF-8 -jar /Users/leodebruyn/code/tooling-force.com/tooling-force.com.jar --action=serverStart --port=8888 --timeoutSec=1800

--action=version --tempFolderPath='/Users/leodebruyn/code/apex-temp' --config='/Users/leodebruyn/code/apex-properties/lionbrave-developer.properties' --projectPath='/Users/leodebruyn/code/lionbrave-developer' --debuggingHeaderConfig='/var/folders/_n/xzft2wm167ggpsytcwr5028m0000gn/T/vlRcO5E/3-apexTraceFlag.conf' --responseFilePath='/Users/leodebruyn/code/lionbrave-developer/.vim-force.com/response_version' --pollWaitMillis=1000 --maxPollRequests=1000 [INFO] # Time taken: 0.043s INFO: tooling-force.com - version: 0.3.8.0; SFDC API Version: 38.0 DEBUG: Used Memory: 36 MB DEBUG: Free Memory: 209 MB DEBUG: Total Memory: 245 MB DEBUG: Max Memory: 3641 MB

output of java -version from command line: java version "1.8.0_131" Java(TM) SE Runtime Environment (build 1.8.0_131-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

content of project-path/.vim-force.com/response_refresh file: RESULT=FAILURE MESSAGE: {"id":5,"text":"spray.json.JsonParser$ParsingException: Unexpected end-of-input at input index 0 (line 1, position 1), expected JSON Value:\n\n^\n","type":"ERROR"}

I am not too familiar with debugging this application since I am new to it, but here is the output from ApexMessages as well, if that helps: --action=refresh --tempFolderPath='/Users/leodebruyn/code/apex-temp' --config='/Users/leodebruyn/code/apex-properties/lionbrave-developer.properties' --projectPath='/Users/leodebruyn/code/lionbrave-developer' --debuggingHeaderConfig='/var/folders/_n/xzft2wm167ggpsytcwr5028m0000gn/T/vlRcO5E/7-apexTraceFlag.conf' --modifiedFilesResultCode=SUCCESS --responseFilePath='/Users/leodebruyn/code/lionbrave-developer/.vim-force.com/response_refresh' --pollWaitMillis=1000 --maxPollRequests=1000 [INFO] # Time taken: 0.007s INFO: Modified file(s) detected. INFO: src/classes/TestDataFactory.cls-meta.xml INFO: src/classes/TestDataFactory.cls INFO: src/classes/TestAccountDeletion.cls

--action=refresh --tempFolderPath='/Users/leodebruyn/code/apex-temp' --config='/Users/leodebruyn/code/apex-properties/lionbrave-developer.properties' --projectPath='/Users/leodebruyn/code/lionbrave-developer' --debuggingHeaderConfig='/var/folders/_n/xzft2wm167ggpsytcwr5028m0000gn/T/vlRcO5E/8-apexTraceFlag.conf' --skipModifiedFilesCheck=true --responseFilePath='/Users/leodebruyn/code/lionbrave-developer/.vim-force.com/response_refresh' --pollWaitMillis=1000 --maxPollRequests=1000 spray.json.JsonParser$ParsingException: Unexpected end-of-input at input index 0 (line 1, position 1), expected JSON Value:

^

[INFO] # Time taken: 0.005s ERROR: Operation failed ERROR: spray.json.JsonParser$ParsingException: Unexpected end-of-input at input index 0 (line 1, position 1), expected JSON Value:^

neowit commented 7 years ago

Your environment looks fine at first glance.

what API version is configured in your package.xml ?

do you need to use proxy to connect to the internet ? If you do then (based on the log) it is not configured.

The problem seems to be with the call to SFDC not returning response in the expected format. When this happens there is nothing can be done on the client. Since you are having this problem with several projects then most likely reason is your network. There is a good chance that the call to SFDC does not actually reach SFDC or it does but some sort of security config prevents it from returning result in expected format.

If above does not give you enough to debug it yourselves then I could send you .jar version which does more debug output. Perhaps we will be able to see what response you get when calling SFDC.

ldebruyn commented 7 years ago

Let's try a debug jar, if that's not too much trouble.

There is nothing weird about my connection - a typical US in-router cable company wifi connection (comcast). I am not aware of any changes, and am able to connect via other tools like Mavensmate. If there has been a change, perhaps more debug info will isolate it.

It does seem to be getting a connection, just having trouble pulling things down. In SF, I do see three sessions under Setup > Security Contrtols > Session Management for my ip address, two which are obviously from logging into the browser (content and UI) and a third that has the right timestamp which has the following properties:

Session Type: API User Type: Standard Login Type: Other Apex API

I am guessing that is vim-force doing its thing.

neowit commented 7 years ago

what API version is configured in your package.xml ?

To run jar file with some more debug output please follow these steps

  1. Make sure that tooling-force.com.jar server is not running. This can be done by killing all java processes

  2. then use this .jar and start server manually (in terminal) like so

    java -Dorg.apache.commons.logging.Log=com.neowit.utils.LogImpl -Dorg.apache.commons.logging.simplelog.defaultlog=debug -Dfile.encoding=UTF-8 -jar /Users/leodebruyn/code/tooling-force.com/tooling-force.com-issue-90.jar --action=serverStart --port=8888 --timeoutSec=1800
  3. then open apex class in vim and call :ApexRefreshProject and paste content of :ApexMessages window here. Also check if on terminal side server reported anything useful, if it did then paste it here as well.

Thanks

ldebruyn commented 7 years ago

Here are the results. I checked for running java processes, then ran the jar with the settings you requested.

Then, I backed up and cleared out any old files and projects, and tried to initialize the project fresh, basically:

:setfiletype apexcode
:ApexValidateJavaConfig
:ApexInitProject

I entered user, name, key, url. The config was good, and the project was set up but once it started to refresh, I get the same errors.

I checked Login History in salesforce setup, and I can see the login in question: Type: Other Apex API Status: Success Browser: Java (Salesforce.com) Platform: Unknown Application: N/A Client Version: N/A API Type: SOAP Partner API Version: 40.0

In my new project folder, I have now got:

Attached are the terminal logs for java and the apex_messages log.

vim-force-apex_messages-output.txt java-terminal-output.txt

neowit commented 7 years ago

Thanks, looks like we are getting somewhere. It fails on parsing debuggingHeaderConfig file.

  1. Can you confirm that you are using latest version of vim-force.com ?

  2. Did you set g:apex_test_debuggingHeader vim config variable yourselves by any chance ? If you did - check that it contains valid json, in format as specified in :help 'g:apex_test_debuggingHeader'

If you believe you did not set g:apex_test_debuggingHeader then it would be worth checking anyway. Execute following command in vim :let g:apex_test_debuggingHeader. If variable is not set you should get error E121: Undefined variable: g:apex_test_debuggingHeader

Assuming you confirmed that this variable is not set - try to execute :ApexRefreshProject again and when it fails check what path was specified by last command for --debuggingHeaderConfig parameter (you will find it in :ApexMessages window). It should point to a temporary file with name ending -apexTraceFlag.conf. Paste content of that file here.

ldebruyn commented 7 years ago

Well I'll be... debugging a program you like to use is like reading a great detective novel.

Looks like it is set after all. Clearing g:apex_test_debuggingHeader fixed it for me.

Note, I literally copy and pasted it from the help file, and it is totally valid JSON. So, thankfully I can continue working now, but the bug is the inability to set g:apex_test_debuggingHeader in .vimrc. That is to say, this is what generates the error:

    let g:apex_test_debuggingHeader = {"All": "Error", "Visualforce": "Error",                                                                                                          
    \ "Workflow": "Error", "Db": "Error", "System": "Error", "Callout": "Error",
    \ "Apex_profiling": "Error", "Apex_code": "Debug", "Validation": "Error"}