dynamicdan / sn-filesync

2-way sync ServiceNow field values to local files
MIT License
66 stars 37 forks source link

Issue with setup #32

Closed TheoSqua closed 8 years ago

TheoSqua commented 8 years ago

Not sure if an issue is the best place for this, but I finally have a bit of time to look into getting filesync running and am having issues with the sync.

I've tried this in our company instance and on a developer instance with multiple machines. Here is the command line output. Any suggestions on what i might be missing? One thing I noticed is the sys_id is blank, but i'm erroring out when getting records as well.

`21:51:48 - info: Potentially syncing changed file to instance /Users/username/sn-filesync/instance/records/script_includes/TaskStateUtilExt.js 21:51:48 - warn: --------- meta data file not yet existing --------------- 21:51:48 - warn: File in question: /Users/username/sn-filesync/instance/records/.sync_data/script_includes/TaskStateUtilExt.js 21:51:48 - warn: --------- meta data file not yet existing --------------- 21:51:48 - warn: File in question: /Users/username/sn-filesync/instance/records/.sync_data/script_includes/TaskStateUtilExt.js 21:51:48 - warn: --------- sync data not yet existing --------------- 21:51:48 - info: Comparing remote version with previous local version... 21:51:48 - debug: snc-client send() path: /sys_script_include.do?JSONv2=&sysparm_record_count=1&sysparm_action=getRecords&displayvalue=true&sysparm_query=name%3DTaskStateUtilExt%5Esys_class_name%3Dsys_script_include 21:51:48 - debug: ------------------------------------------------------- 21:51:48 - debug: <!DOCTYPE html>

Redirecting

21:51:48 - debug: ------------------------------------------------------- 21:51:48 - debug: "<!DOCTYPE html>\n<html lang=\"en\">\n\n\t<meta charset=\"UTF-8\">\n\tRedirecting\n\t\n\n\n

\n\n" 21:51:48 - warn: --------- meta data file not yet existing --------------- 21:51:48 - warn: File in question: /Users/username/sn-filesync/instance/records/.sync_data/script_includes/TaskStateUtilExt.js notifying with code: -500 21:51:48 - error: Error: Response missing "records" key: "<!DOCTYPE html>\n<html lang=\"en\">\n\n\t<meta charset=\"UTF-8\">\n\tRedirecting\n\t\n\n\n

\n\n" Check server logs. at validateResponse (/Users/username/sn-filesync/lib/snc-client.js:112:24) at Request.handleResponse (/Users/username/sn-filesync/lib/snc-client.js:147:27) at emitTwo (events.js:106:13) at Request.emit (events.js:191:7) at Request.mixin._fireSuccess (/Users/username/sn-filesync/node_modules/@mishguru/restler/lib/restler.js:247:10) at /Users/username/sn-filesync/node_modules/@mishguru/restler/lib/restler.js:179:20 at IncomingMessage.parsers.auto (/Users/username/sn-filesync/node_modules/@mishguru/restler/lib/restler.js:416:7) at Request.mixin._encode (/Users/username/sn-filesync/node_modules/@mishguru/restler/lib/restler.js:216:29) at /Users/username/sn-filesync/node_modules/@mishguru/restler/lib/restler.js:175:16 at Gunzip.onEnd (zlib.js:227:5) 21:51:48 - error: handleError context: { table: 'sys_script_include', field: 'script', query: 'name=TaskStateUtilExt', sys_id: false, payload: { script: 'var TaskStateUtilExt = Class.create();\nTaskStateUtilExt.prototype = Object.extendsObject(TaskStateUtil, {\n\tATTR_WORKING_STATES : "working_states",\n\tATTR_IDLE_STATES: "idle_states",\n\tgetIdleStates : function() {\n\t\tvar attribute = this.stateElement\n\n\t\t.getAttribute(this.ATTR_IDLE_STATES);\n\n\t\tif (!attribute)\n\t\t\treturn;\n\n\n\t\tvar states = attribute.split(";");\n\t\tthis.idleStates = states;\n\t},\n\tgetWorkingStates : function() {\n\t\tvar attribute = this.stateElement\n\t\t.getAttribute(this.ATTR_WORKING_STATES);\n\n\t\tif (!attribute)\n\t\t\treturn;\n\n\t\tvar states = attribute.split(";");\n\t\tthis.workingStates = states;\n\t},\n\tisIdleState : function(state) {\n\t state = state + "";\n var arrUtil = new ArrayUtil();\n if (arrUtil.contains(this.idleStates, state))\n return true;\n\n return false;\n\t},\n\n\ttype: \'TaskStateUtilExt\'\n\n});\n\n//test1234567\n' } } 21:51:48 - warn: --------- meta data file not yet existing --------------- 21:51:48 - warn: File in question: /Users/username/sn-filesync/instance/records/.sync_data/script_includes/TaskStateUtilExt.js notifying with code: -3 21:51:48 - warn: Instance record is not in sync with local env ("TaskStateUtilExt"). 21:51:48 - error: Could not send file: /Users/username/sn-filesync/instance/records/script_includes/TaskStateUtilExt.js`

dynamicdan commented 8 years ago

Hi,

Your error looks very strange. From a FileSync perspective the attribute "records" is missing from the response. I actually suspect that your JSON response from the instance is completely bogus. Perhaps you have the wrong URL or extra security or something for the user you are testing with.

How to diagnose:

  1. Perform first a demo search to ensure instance connection is viable (--search on command line)
  2. Perform a --search --download to ensure records can be received.
  3. Turn on debug mode (debug: true in config) and look for the "path" that is used for the JSONv2 query. You can copy this into a web browser to compare results. You should get exactly 1 record match and it should be rendered as JSON in the web browser.

If things still aren't working then let me know what instance version you are using (/stats.do), if you can get it working on other instances (and with an admin account) and if perhaps the rest API stuff is turned off or plugins for JSONv2 are not activated.

If you can download records via search then you shouldn't have any issues. If not then you have a problem with your config/settings/instance/network/user access etc.

TheoSqua commented 8 years ago

I had tried reinstalling sn-filesync and it didn't help. Today I tried uninstalling node/npm and completely starting over. A fresh install fixed the issue. I did a diffcheck on my config files and they are the same, so no idea what caused it.

Thanks for helping me look into it though. I'm still a bit new to node and local development but i'm excited to finally have filesync working!

dynamicdan commented 8 years ago

Glad to read it's working.

npm install is your friend but sometimes there are dependency issues. In any case, sounds like a setup issue that has been fixed.