Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 507086

Summary: 404 error in browser console with untracked files
Product: [ECD] Orion Reporter: Remy Suen <remy.suen>
Component: GitAssignee: Remy Suen <remy.suen>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: Michael_Rennie
Version: 13.0   
Target Milestone: 13.0   
Hardware: All   
OS: All   
See Also: https://git.eclipse.org/r/85467
https://git.eclipse.org/c/orion/org.eclipse.orion.server.git/commit/?id=509e690e61b1874466129817492d9b48fcaf336d
Whiteboard:

Description Remy Suen CLA 2016-11-04 22:45:08 EDT
Version: OrionHub

I can also reproduce it with the code in Git when testing locally on Electron.

1. Create a file in a folder under Git source control.
2. Open the 'Git' view.
3. You'll see a 404 GET failure in the console.

If I try to open the link myself in a browser, I get the following JSON.

{
  "Severity":"Ok",
  "Message":"modules/orionode/.npmrc not found in index",
  "HttpCode":404,
  "BundleId":"org.eclipse.orion.server.core",
  "Code":0
}

gitPlugin.js:1 GET https://orionhub.org/gitapi/index/file/rcjsuen-OrionContent/org.eclipse.orion.client/modules/orionode/.npmrc 404 (Not Found)
read	@	GitFileImpl.js:86
m	@	gitPlugin.js:1
p	@	gitPlugin.js:1
postMessage (async)		
s.postMessage	@	pluginregistry.js:1141
postMessage	@	pluginregistry.js:1210
c	@	pluginregistry.js:264
i.(anonymous function)	@	pluginregistry.js:434
(anonymous function)	@	serviceregistry.js:147
o	@	fileClient.js:30
read	@	fileClient.js:552
_loadSingleFile	@	resourceComparer.js:482
(anonymous function)	@	resourceComparer.js:477
_getFilesContents	@	resourceComparer.js:476
(anonymous function)	@	resourceComparer.js:564
n	@	Deferred.js:70
e	@	Deferred.js:144
e	@	Deferred.js:28
attributes (async)		
(anonymous function)	@	Deferred.js:46
t	@	Deferred.js:58
r	@	Deferred.js:196
resolve	@	Deferred.js:227
p	@	pluginregistry.js:414
a	@	pluginregistry.js:1315
(anonymous function)	@	pluginregistry.js:1325
d	@	pluginregistry.js:1323
postMessage (async)		
s	@	gitPlugin.js:1
(anonymous function)	@	gitPlugin.js:1
o	@	gitPlugin.js:1
e	@	gitPlugin.js:1
e	@	gitPlugin.js:1
attributes (async)		
(anonymous function)	@	gitPlugin.js:1
t	@	gitPlugin.js:1
i	@	gitPlugin.js:1
resolve	@	gitPlugin.js:1
a.onload	@	gitPlugin.js:1
Comment 1 Remy Suen CLA 2016-11-04 22:59:56 EDT
Here are the logs from Electron. Since the error message is different, they may potentially be two different bugs. I'm not sure though. Also, if the error doesn't trigger, it may be because you have multiple files that are unstaged. To trigger the file, expand the untracked file so that the embedded compare pane will open.

{
  "Severity":"Error",
  "Message":"Cannot read property 'id' of undefined"
}

GET http://localhost:8081/gitapi/index/file/modules/orionode/.npmrc 404 (Cannot read property 'id' of undefined)_xhr @ xhr.js:175
read @ GitFileImpl.js:86
_callMethod @ plugin.js:273
_handleMessage @ plugin.js:326
Comment 2 Remy Suen CLA 2016-11-18 23:14:32 EST
(In reply to Remy Suen from comment #1)
> Here are the logs from Electron. Since the error message is different, they
> may potentially be two different bugs.

It's a different code path and the actual physical is in a different repository so I've opened bug 507797 for the Node integration issue.
Comment 3 Michael Rennie CLA 2016-11-21 14:26:24 EST
(In reply to Remy Suen from comment #2)
> (In reply to Remy Suen from comment #1)
> > Here are the logs from Electron. Since the error message is different, they
> > may potentially be two different bugs.
> 
> It's a different code path and the actual physical is in a different
> repository so I've opened bug 507797 for the Node integration issue.

Yeah, I think this one is a bit more involved, since it ends up just sending an XHR to read a file that does not exist vs. a failed index lookup.

We added a new flag in 13.0 for XHR requests called "read-if-exists", that we might be able to use / extend to work in this case. Its current implementation is found in ServletFileStoreHandler.java and /lib/file.js.
Comment 4 Remy Suen CLA 2016-11-21 15:41:48 EST
(In reply to Michael Rennie from comment #3)
> Yeah, I think this one is a bit more involved, since it ends up just sending
> an XHR to read a file that does not exist vs. a failed index lookup.

The Java implementation is also a failed index look up. The error from comment 0 is coming from GitIndexHandlerV1's handleGet(*) method.

> We added a new flag in 13.0 for XHR requests called "read-if-exists", that
> we might be able to use / extend to work in this case. Its current
> implementation is found in ServletFileStoreHandler.java and /lib/file.js.

With that in mind though, it seems like we should be using the 'read-if-exists' property for both the Java case and the Node case. When I think back about it, 404 is a valid error case for all intents and purposes as the request is asking the server for a file in the index but it doesn't exist in the index. Sending back a response of an empty string is actually incorrect because the receiver now doesn't know if a) the file doesn't exist or b) the file exists but the file is 0 bytes large and completely empty.
Comment 5 Eclipse Genie CLA 2016-11-22 05:05:23 EST
New Gerrit change created: https://git.eclipse.org/r/85467
Comment 7 Remy Suen CLA 2016-11-24 16:02:42 EST
Closing this as the change has been merged into master.

The changes to the Git client code and the Node server is tracked by bug 507797.