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

handle composite u-like-of objects (eg h-cites) #28

Open
dougbeal opened this issue Jul 16, 2018 · 4 comments

Comments

Projects
None yet
2 participants
@dougbeal
Copy link

commented Jul 16, 2018

bridgy error on like

https://fed.brid.gy/log?start_time=1531777594&key=https%3A%2F%2Fdougbeal.com%2F2018%2F07%2F16%2Fryan-barrett-interesting-unintended-consequence-of-federation-mastodon-for-tech-folks%2F+https%3A%2F%2Fmastodon.technology%2F%40snarfed%2F100119606571241751

2018-07-16 21:46:33.446730 I requests.get https://mastodon.technology/@snarfed/100119606571241751 {'headers': {u'Accept': u'...', u'User-Agent': u'...'}} 2018-07-16 21:46:33.607850 I Got 200 headers:{'x-request-id': Got 200 headers:{'x-request-id': 'ae85c544-36a7-419a-9a19-cf8ca682f4d9', 'x-xss-protection': '1; mode=block', 'x-content-type-options': 'nosniff', 'content-encoding': 'gzip', 'transfer-encoding': '', 'strict-transport-security': 'max-age=31536000', 'vary': 'Accept,Accept-Encoding', 'x-runtime': '0.026819', 'server': 'Mastodon', 'connection': 'keep-alive', 'etag': 'W/"9c5ec0bf5a0b9234f69bbca81eadcfa5"', 'link': '; rel="alternate"; type="application/atom+xml", ; rel="alternate"; type="application/activity+json"', 'cache-control': 'max-age=180, public', 'date': 'Mon, 16 Jul 2018 21:46:33 GMT', 'x-frame-options': 'DENY', 'content-type': 'application/activity+json; charset=utf-8'}, 'x-xss-protection': '1; mode=block', 'x-content-type-options': 'nosniff', 'content-encoding': 'gzip', 'transfer-encoding': '', 'strict-transport-security': 'max-age=31536000', 'vary': 'Accept,Accept-Encoding', 'x-runtime': '0.026819', 'server': 'Mastodon', 'connection': 'keep-alive', 'etag': 'W/"9c5ec0bf5a0b9234f69bbca81eadcfa5"', 'link': '; rel="alternate"; type="application/atom+xml", ; rel="alternate"; type="application/activity+json"', 'cache-control': 'max-age=180, public', 'date': 'Mon, 16 Jul 2018 21:46:33 GMT', 'x-frame-options': 'DENY', 'content-type': 'application/activity+json; charset=utf-8'} 2018-07-16 21:46:33.608290 I {"@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"manuallyApprovesFollowers":"as:manuallyApprovesFollowers","sensitive":"as:sensitive","movedTo":"as:movedTo","Hashtag":"as:Hashtag","ostatus":"http://ostatus.org#","atomUri":"ostatus:atomUri","inReplyToAtomUri":"ostatus:inReplyToAtomUri","conversation":"ostatus:conversation","toot":"http://joinmastodon.org/ns#","Emoji":"toot:Emoji","focalPoint":{"@container":"@list","@id":"toot:focalPoint"},"featured":"toot:featured","schema":"http://schema.org#","PropertyValue":"schema:PropertyValue","value":"schema:value"}],"id":"https://mastodon.technology/users/snarfed/statuses/100119606571241751","type":"Note","summary":null,"content":"\u003cp\u003eInteresting unintended consequence of federation: when you post a link, \u0026gt;1k mastodon nodes all fetch it at the same time to render a link preview, which results in a small DDoS.\u003c/p\u003e","inReplyTo":null,"published":"2018-05-30T18:12:37Z","url":"https://mastodon.technology/@snarfed/100119606571241751","attributedTo":"https://mastodon.technology/users/snarfed","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://mastodon.technology/users/snarfed/followers"],"sensitive":false,"atomUri":"https://mastodon.technology/users/snarfed/statuses/100119606571241751","inReplyToAtomUri":null,"conversation":"tag:mastodon.technology,2018-05-30:objectId=5634750:objectType=Conversation","attachment":[{"type":"Document","mediaType":"image/png","url":"https://static.mastodon.technology/media_attachments/files/000/979/283/original/d931a7f3acc5b062.png","name":null}],"tag":[]} 2018-07-16 21:46:33.610470 I source target: https://dougbeal.com/2018/07/16/ryan-barrett-interesting-unintended-consequence-of-federation-mastodon-for-tech-folks/ https://mastodon.technology/@snarfed/100119606571241751 2018-07-16 21:46:33.787349 I requests.get https://mastodon.technology/users/snarfed {'headers': {u'Accept': u'...', u'User-Agent': u'...'}} 2018-07-16 21:46:34.453160 I Got 200 headers:{'x-request-id': Got 200 headers:{'x-request-id': '476bba7b-9dc6-4559-a3bf-40c4e91b2ce1', 'x-xss-protection': '1; mode=block', 'x-content-type-options': 'nosniff', 'content-encoding': 'gzip', 'transfer-encoding': '', 'strict-transport-security': 'max-age=31536000', 'vary': 'Accept,Accept-Encoding', 'x-runtime': '0.523285', 'server': 'Mastodon', 'connection': 'keep-alive', 'etag': 'W/"6ccc9fcd4d6d65f76e2439e3889d96ca"', 'link': '; rel="lrdd"; type="application/xrd+xml", ; rel="alternate"; type="application/atom+xml", ; rel="alternate"; type="application/activity+json"', 'cache-control': 'max-age=180, public', 'date': 'Mon, 16 Jul 2018 21:46:34 GMT', 'x-frame-options': 'DENY', 'content-type': 'application/activity+json; charset=utf-8'}, 'x-xss-protection': '1; mode=block', 'x-content-type-options': 'nosniff', 'content-encoding': 'gzip', 'transfer-encoding': '', 'strict-transport-security': 'max-age=31536000', 'vary': 'Accept,Accept-Encoding', 'x-runtime': '0.523285', 'server': 'Mastodon', 'connection': 'keep-alive', 'etag': 'W/"6ccc9fcd4d6d65f76e2439e3889d96ca"', 'link': '; rel="lrdd"; type="application/xrd+xml", ; rel="alternate"; type="application/atom+xml", ; rel="alternate"; type="application/activity+json"', 'cache-control': 'max-age=180, public', 'date': 'Mon, 16 Jul 2018 21:46:34 GMT', 'x-frame-options': 'DENY', 'content-type': 'application/activity+json; charset=utf-8'} 2018-07-16 21:46:34.453630 I {"@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"manuallyApprovesFollowers":"as:manuallyApprovesFollowers","sensitive":"as:sensitive","movedTo":"as:movedTo","Hashtag":"as:Hashtag","ostatus":"http://ostatus.org#","atomUri":"ostatus:atomUri","inReplyToAtomUri":"ostatus:inReplyToAtomUri","conversation":"ostatus:conversation","toot":"http://joinmastodon.org/ns#","Emoji":"toot:Emoji","focalPoint":{"@container":"@list","@id":"toot:focalPoint"},"featured":"toot:featured","schema":"http://schema.org#","PropertyValue":"schema:PropertyValue","value":"schema:value"}],"id":"https://mastodon.technology/users/snarfed","type":"Person","following":"https://mastodon.technology/users/snarfed/following","followers":"https://mastodon.technology/users/snarfed/followers","inbox":"https://mastodon.technology/users/snarfed/inbox","outbox":"https://mastodon.technology/users/snarfed/outbox","featured":"https://mastodon.technology/users/snarfed/collections/featured","preferredUsername":"snarfed","name":"Ryan Barrett","summary":"\u003cp\u003e\u003ca href=\"https://snarfed.org\" rel=\"nofollow noopener\" target=\"_blank\"\u003e\u003cspan class=\"invisible\"\u003ehttps://\u003c/span\u003e\u003cspan class=\"\"\u003esnarfed.org\u003c/span\u003e\u003cspan class=\"invisible\"\u003e\u003c/span\u003e\u003c/a\u003e\u003c/p\u003e","url":"https://mastodon.technology/@snarfed","manuallyApprovesFollowers":false,"publicKey":{"id":"https://mastodon.technology/users/snarfed#main-key","owner":"https://mastodon.technology/users/snarfed","publicKeyPem":"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4zEoZNdw2Rc4y2vhQjq2\n3+QlfE/X1uW4QJglIBGbLEgydF+8NTGuSamejlPMdetcrtxE3WzKbkbyicrAthuH\njWaz5k5RwtEcvXYyrFRsnR3R2g+vLzYNyCL6N8im3shKe/6ZYi0FWk4eE7hUAtXS\n4+PU4WHCD5hyuhIn/TKE9MKwkRAF5a7Qf+86zNyxQn4ME/jzR8ewY6OQHlQYmKfS\nb07gsUC9liSRQsUkV+uMUxLtbrlv40ZI6mUDoQyB0HGNyc39iEFufgTxOPyMQmoP\nBT4/LZ1stSmaA8tOrq1WAT/g/KZlon0Bnssic3D/4i+iL9YCxyazmVtF6T0juw41\nYQIDAQAB\n-----END PUBLIC KEY-----\n"},"tag":[],"attachment":[],"endpoints":{"sharedInbox":"https://mastodon.technology/inbox"},"icon":{"type":"Image","mediaType":"image/jpeg","url":"https://static.mastodon.technology/accounts/avatars/000/023/507/original/c183cf1e3a60f5c3.jpg"},"image":{"type":"Image","mediaType":"image/jpeg","url":"https://static.mastodon.technology/accounts/headers/000/023/507/original/977013e803161a99.jpg"}} 2018-07-16 21:46:34.580490 E Expected dict, got [{u'url': u'https://mastodon.technology/@snarfed/100119606571241751'}, {u'url': u'https://mastodon.technology/@snarfed/100119606571241751', u'author': {u'url': u'https://mastodon.technology/@snarfed', u'image': [{u'url': u'https://static.mastodon.technology/accounts/avatars/000/023/507/original/c183cf1e3a60f5c3.jpg'}], u'displayName': u'Ryan Barrett', u'objectType': u'person'}, u'displayName': u'Ryan Barrett (@snarfed@mastodon.technology)', u'objectType': u'article', u'summary': u'Interesting unintended consequence of federation: when you post a link, >1k mastodon nodes all fetch it at the same time to render a link preview, which results in a small DDoS.'}] Traceback (most recent call last): File "/base/data/home/apps/s~bridgy-federated/1.409068985746702557/local/lib/python2.7/site-packages/webapp2.py", line 1535, in __call__ rv = self.handle_exception(request, response, e) File "/base/data/home/apps/s~bridgy-federated/1.409068985746702557/local/lib/python2.7/site-packages/webapp2.py", line 1529, in __call__ rv = self.router.dispatch(request, response) File "/base/data/home/apps/s~bridgy-federated/1.409068985746702557/local/lib/python2.7/site-packages/webapp2.py", line 1278, in default_dispatcher return route.handler_adapter(request, response) File "/base/data/home/apps/s~bridgy-federated/1.409068985746702557/local/lib/python2.7/site-packages/webapp2.py", line 1102, in __call__ return handler.dispatch() File "/base/data/home/apps/s~bridgy-federated/1.409068985746702557/local/lib/python2.7/site-packages/webapp2.py", line 572, in dispatch return self.handle_exception(e, self.app.debug) File "/base/data/home/apps/s~bridgy-federated/1.409068985746702557/local/lib/python2.7/site-packages/webapp2.py", line 570, in dispatch return method(*args, **kwargs) File "/base/data/home/apps/s~bridgy-federated/1.409068985746702557/webmention.py", line 47, in post self.try_activitypub() File "/base/data/home/apps/s~bridgy-federated/1.409068985746702557/webmention.py", line 144, in try_activitypub as2.from_as1(source_obj), target=target_obj, key=key) File "/base/data/home/apps/s~bridgy-federated/1.409068985746702557/local/lib/python2.7/site-packages/granary/as2.py", line 92, in from_as1 'object': from_as1(obj.get('object'), context=None), File "/base/data/home/apps/s~bridgy-federated/1.409068985746702557/local/lib/python2.7/site-packages/granary/as2.py", line 65, in from_as1 raise ValueError('Expected dict, got %r' % obj) ValueError: Expected dict, got [{u'url': u'https://mastodon.technology/@snarfed/100119606571241751'}, {u'url': u'https://mastodon.technology/@snarfed/100119606571241751', u'author': {u'url': u'https://mastodon.technology/@snarfed', u'image': [{u'url': u'https://static.mastodon.technology/accounts/avatars/000/023/507/original/c183cf1e3a60f5c3.jpg'}], u'displayName': u'Ryan Barrett', u'objectType': u'person'}, u'displayName': u'Ryan Barrett (@snarfed@mastodon.technology)', u'objectType': u'article', u'summary': u'Interesting unintended consequence of federation: when you post a link, >1k mastodon nodes all fetch it at the same time to render a link preview, which results in a small DDoS.'}]

(Originally published at: https://crw.moe/b/X6)

@snarfed

This comment has been minimized.

Copy link
Owner

commented Jul 16, 2018

thanks for filing! looks like bridgy fed handles simple url values for u-like-of etc right now, but not composite objects like h-cites. should be a straightforward fix. PRs welcome!

@dougbeal

This comment has been minimized.

Copy link
Author

commented Jul 17, 2018

The error is in granary?

(Originally published at: https://crw.moe/b/XM)

@snarfed

This comment has been minimized.

Copy link
Owner

commented Jul 17, 2018

yes, the composite object support probably needs to go in as2.from_as1, and maybe elsewhere.

good news is it's easy to construct a test case from this input!

@snarfed snarfed changed the title snarfed/bridgy-fed – bridgy error on like handle composite u-like-of objects (eg h-cites) Oct 17, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.