Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect href link for ONE_TO_ONE relation with OID as id type #279

Closed
shaileshpandit opened this issue May 2, 2018 · 5 comments
Closed
Labels
Milestone

Comments

@shaileshpandit
Copy link

shaileshpandit commented May 2, 2018

After creating a link to other document with OID as id type, the href in link is incorrect

Expected Behavior

href in owning document should be object id string instead of whole json object
"href": "/test/collother/5ae94eb4b634b2c96dc9f242"

Current Behavior

href in owning document is whole json object
"href": "/test/collother/{"$oid":"5ae94eb4b634b2c96dc9f242"}"

Context

was trying to simply link other document from one document

Environment

05:19:20.724 [main] INFO org.restheart.Bootstrapper - version 3.2.2
05:19:21.687 [main] INFO org.restheart.Bootstrapper - MongoDB version 3.6.4,

Steps to Reproduce

http -a a:a PUT localhost:8080/test
	HTTP/1.1 201 Created
http -a a:a PUT localhost:8080/test/collother
	HTTP/1.1 201 Created
http -a a:a POST localhost:8080/test/collother name="test"
	HTTP/1.1 201 Created
	Location: http://localhost:8080/test/collother/5ae94eb4b634b2c96dc9f242
http -a a:a PUT localhost:8080/test/collowing rels:='[{"rel":"other","type":"ONE_TO_ONE","role":"OWNING","target-coll":"collother","ref-field":"otherId"}]'
	HTTP/1.1 201 Created
http -a a:a POST localhost:8080/test/collowing addr="tetsaddr" otherId:='{"$oid":"5ae94eb4b634b2c96dc9f242"}'
	HTTP/1.1 201 Created
	Location: http://localhost:8080/test/collowing/5ae95182b634b2c96dc9f2c1
http -a a:a GET localhost:8080/test/collowing/5ae95182b634b2c96dc9f2c1
	HTTP/1.1 200 OK
	{
	    "_etag": {
	        "$oid": "5ae9518263445900055d3984"
	    },
	    "_id": {
	        "$oid": "5ae95182b634b2c96dc9f2c1"
	    },
	    "_links": {
	        "other": {
	            "href": "/test/collother/{\"$oid\":\"5ae94eb4b634b2c96dc9f242\"}"
	        }
	    },
	    "addr": "tetsaddr",
	    "otherId": {
	        "$oid": "5ae94eb4b634b2c96dc9f242"
	    }
	}
http -a a:a GET localhost:8080/test/collother/{\"\$oid\":\"5ae94eb4b634b2c96dc9f242\"}
	HTTP/1.1 404 Not Found
	{
	    "http status code": 404,
	    "http status description": "Not Found",
	    "message": "document '{'$oid':'5ae94eb4b634b2c96dc9f242'}' does not exist"
	}
http -a a:a GET localhost:8080/test/collother/5ae94eb4b634b2c96dc9f242
	HTTP/1.1 200 OK
	{
	    "_etag": {
	        "$oid": "5ae94eb463445900055d397f"
	    },
	    "_id": {
	        "$oid": "5ae94eb4b634b2c96dc9f242"
	    },
	    "name": "test"
	}

Possible Implementation

@mkjsix
Copy link
Member

mkjsix commented May 2, 2018

@ujibang this looks like a regression, I've never noticed such an issue before.

@ujibang
Copy link
Contributor

ujibang commented May 8, 2018

fixed in 6c397e7

@ujibang ujibang closed this as completed May 8, 2018
@mkjsix
Copy link
Member

mkjsix commented May 9, 2018

We're going to release version 3.3 final this week, it will include this fix as well.

@mkjsix
Copy link
Member

mkjsix commented May 10, 2018

@shaileshpandit yesterday we've released the fix in both RESTHeart 3.3.0 and 3.2.3. Beware that version 3.3 introduces some different behaviors for PUT and POST, so have a look at the release notes before jumping: https://github.com/SoftInstigate/restheart/releases

@mkjsix mkjsix modified the milestones: 3.3.0, 3.2.3 May 10, 2018
@shaileshpandit
Copy link
Author

Thanks, works as expected in 3.3.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants