Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 389758 - [Object object] - Server response object on remote import is HTML, not JSON
Summary: [Object object] - Server response object on remote import is HTML, not JSON
Status: VERIFIED FIXED
Alias: None
Product: Orion
Classification: ECD
Component: Server (show other bugs)
Version: 0.5   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: 1.0 RC2   Edit
Assignee: John Arthorne CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-09-17 15:35 EDT by Susan McCourt CLA
Modified: 2012-10-12 09:58 EDT (History)
2 users (show)

See Also:
susan: review+
susan: review? (ken_walker)


Attachments
screenshot (878 bytes, image/png)
2012-09-17 15:35 EDT, Susan McCourt CLA
no flags Details
screenshot of failure after import (9.04 KB, image/png)
2012-10-10 16:43 EDT, Susan McCourt CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Susan McCourt CLA 2012-09-17 15:35:53 EDT
Created attachment 221172 [details]
screenshot

I've just added support for the new "remote import from Zip at a URL" feature.  It is mostly working, but after it completes I get the bogus info message with [Object object] in the status area.

It appears that the problem is we are trying to JSON parse some HTML text.

For example, here is the fileImpl code for the "remoteImport" call:
remoteImport: function(targetLocation, options) {
	var headerData = {
		"Orion-Version": "1"
	};
	if (options.OptionHeader) {
		headerData["X-Xfer-Options"] = options.OptionHeader;
	}
	return xhr("POST", targetLocation, {
		headers: headerData,
		data: JSON.stringify(options),
		timeout: 15000
	}).then(function(result) {
		return result.response ? JSON.parse(result.response) : null;
	});
},

The result.response is not json, though, it is HTML.
args: Object
response: "<head></head><body><textarea>{}</textarea></body>"
responseText: "<head></head><body><textarea>{}</textarea></body>"
status: 201
url: "/xfer/import/I/Dummy?source=http://git.eclipse.org/c/platform/eclipse.platform.git/plain/platform/org.eclipse.platform/3_1SplashPsd.zip"
xhr: XMLHttpRequest
__proto__: Object

John theorized that this may have been broken with the switch to plain xhr.

Another question is whether the client should be showing a message at all on success, but I think that's a separate issue.  I suspect this kind of problem accounts for the [Object object] problems we have elsewhere (on errors, not just info)
Comment 1 Susan McCourt CLA 2012-09-17 15:36:28 EDT
marking M2 to keep it on radar, but this could be handled in the RC's if need be.
Comment 2 John Arthorne CLA 2012-09-18 10:34:43 EDT
This HTML response on import was added here:

http://git.eclipse.org/c/orion/org.eclipse.orion.server.git/commit/?id=219dc2342753ffd53b74355bf769c8a68d0b4348

Szymon do you know why this HTML response is being sent? You did this as part of switch away from Dojox.form.Uploader. Anton has since changed a lot of this so it may no longer be needed.
Comment 3 John Arthorne CLA 2012-10-10 15:22:35 EDT
I can eliminate the HTML response here, but I don't know why we were doing it in the first place. The [Object] object message isn't currently appearing from what I can tell in my testing, so I think it is best to defer to post 1.0.
Comment 4 Susan McCourt CLA 2012-10-10 16:43:22 EDT
Created attachment 222151 [details]
screenshot of failure after import

the "Object object" is still happening after an HTTP import.
Comment 5 Susan McCourt CLA 2012-10-10 16:46:41 EDT
The steps I used to reproduce "Object object" are:

1) create a new project, Dummy
2) create a folder within that project "testing"
3) select testing folder and choose Actions->Import from HTTP...
4) paste in this URL
http://git.eclipse.org/c/platform/eclipse.platform.git/plain/platform/org.eclipse.platform/3_1SplashPsd.zip
5) hit enter

You'll get the zip imported but you'll also get the info message with object object.

The reason this is important is that it causes "object object" to appear in the "Create new Content" use case as well.

1) Open a navigator at the root
2) Choose Sample HTML5 Site from the new content area
3) You'll get the site but you'll also get the object object problem.
Comment 6 John Arthorne CLA 2012-10-11 11:56:45 EDT
There are two ways to do here:

1) Response body is empty. This is what the rest of our import POST requests do today. See: http://wiki.eclipse.org/Orion/Server_API/Transfer_API

2) Response body contains JSON representation of the file or directory that was created. This is what the response contains for the simple "create directory" API.

Open 1) is the simplest thing to do at this point. For 2) it is not obvious what to return, because depending on the arguments it could be a single file that was created, or a tree of files. Unless there is something valuable a client can do with this result I think it is better to keep it empty (201 CREATED). I have implemented this option and verified that is gets rid of the funny string with Susan's steps below. It is in this branch:

http://git.eclipse.org/c/orion/org.eclipse.orion.server.git/commit/?h=johna/bug389758&id=a1edb7c4a402324532b78c66cd61ec6da687d1b7

Susan I guess it is difficult for your to verify a server side fix. Do you want to try it at some point against my local running server.
Comment 7 Susan McCourt CLA 2012-10-11 12:44:55 EDT
(In reply to comment #6)
> There are two ways to do here:
> 
> 1) Response body is empty. This is what the rest of our import POST requests
> do today. See: http://wiki.eclipse.org/Orion/Server_API/Transfer_API
> 
> 2) Response body contains JSON representation of the file or directory that
> was created. This is what the response contains for the simple "create
> directory" API.
> 
> Open 1) is the simplest thing to do at this point. For 2) it is not obvious
> what to return, because depending on the arguments it could be a single file
> that was created, or a tree of files. Unless there is something valuable a
> client can do with this result I think it is better to keep it empty (201
> CREATED). I have implemented this option and verified that is gets rid of
> the funny string with Susan's steps below. It is in this branch:
> 
> http://git.eclipse.org/c/orion/org.eclipse.orion.server.git/commit/?h=johna/
> bug389758&id=a1edb7c4a402324532b78c66cd61ec6da687d1b7

That solution makes sense to me, the code looks good.

> 
> Susan I guess it is difficult for your to verify a server side fix. Do you
> want to try it at some point against my local running server.

yep, I'll ping you
Comment 8 Susan McCourt CLA 2012-10-11 15:36:22 EDT
John, I tried to ping you a couple times to run the fix, but you are not online.
I +1 the change from a code/API point of view, and added Ken for review, so he can look at the change with you.  (or ping me tomorrow).
Comment 10 John Arthorne CLA 2012-10-12 09:58:15 EDT
Verified in I20121011-2230.