JSON-LD handling inconsistency
Environment
- Installation type (OTP or From Source): I believe from source.
- Pleroma version: 2.1.2 and b225c357
- Elixir version:
$ elixir -v
warning: the VM is running with native name encoding of latin1 which may cause Elixir to malfunction as it expects utf8. Please ensure your locale is set to UTF-8 (which can be verified by running "locale" in your shell)
Erlang/OTP 21 [erts-10.3.5.13] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] [dtrace]
Elixir 1.10.4 (compiled with Erlang/OTP 21)
- Operating system: FreeBSD dev 12.1-RELEASE-p7 FreeBSD 12.1-RELEASE-p7 GENERIC amd64
- PostgreSQL version (
psql -V
): psql (PostgreSQL) 12.4
Bug description
Pleroma seems to handle JSON-LD data differently if no space between fields is present.
I am writing some code that responds to /users/USERNAME requests. I generate them from Pleroma by searching for a user. My code receives 3 requests: /.well-known/host-meta /.well-known/webfinger /users/USERNAME
Then the last requests is completed, the search field populates the username in question. This is not happening.
Digging through the JSON-LD, the only difference between a working response and one Pleroma does not accept is that the working response has spaces between each JSON field, whereas the non-working response has none. For example, this appears to work:
{"@context": ["https://www.w3.org/ns/activitystreams", "https://p.farhan.codes/schemas/litepub-0.1.jsonld", {"@language": "und"}], "attachment": [], "capabilities": {"acceptsChatMessages": true}, "discoverable": false, "endpoints": {"oauthAuthorizationEndpoint": "https://p.farhan.codes/oauth/authorize", "oauthRegistrationEndpoint": "https://p.farhan.codes/api/v1/apps", "oauthTokenEndpoint": "https://p.farhan.codes/oauth/token", "sharedInbox": "https://p.farhan.codes/inbox", "uploadMedia": "https://p.farhan.codes/api/ap/upload_media"}, "followers": "https://p.farhan.codes/users/fedilogue/followers", "following": "https://p.farhan.codes/users/fedilogue/following", "id": "https://p.farhan.codes/users/fedilogue", "inbox": "https://p.farhan.codes/users/fedilogue/inbox", "manuallyApprovesFollowers": false, "name": "fedilogue", "outbox": "https://p.farhan.codes/users/fedilogue/outbox", "preferredUsername": "fedilogue", "publicKey": {"id": "https://p.farhan.codes/users/fedilogue#main-key", "owner": "https://p.farhan.codes/users/fedilogue", "publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAn5JI+uBbt3w0tPekK+UD\naQLRG220XztYLEE1gC8eGYctYgrTX0wruNP+CFap1VsvyWxRoitNjFLDD3pwYxK9\n+k6P459ekL0fSRqQ0bzOQ5Vb22PBs9iOKonV9FSljCcDg0kc3cvxCeU246BMurGI\nIs0vWk3UwygkeMo+rYXDluTtuSvZs+2ume2JYgrtcQoDH5YzU+76dRLYfd1+xEFo\nP+K0hFb7+LhwGwDuLtTUYQ39kqm2jnC9/3W5yyweBqh05iQ0joDC0nuoZpjvT7on\n2Obwluci30Q2xS1i+5244qr9Ouq1EK+9kdf15RMMOH1Azumho1YNFoVZlcxy2bar\n6wIDAQAB\n-----END PUBLIC KEY-----\n\n"}, "summary": "", "tag": [], "type": "Person", "url": "https://p.farhan.codes/users/fedilogue"}
This fails:
{"@context":["https://www.w3.org/ns/activitystreams","https://p.farhan.codes/schemas/litepub-0.1.jsonld",{"@language":"und"}],"attachment":[],"capabilities":{"acceptsChatMessages":true},"discoverable":false,"endpoints":{"oauthAuthorizationEndpoint":"https://p.farhan.codes/oauth/authorize","oauthRegistrationEndpoint":"https://p.farhan.codes/api/v1/apps","oauthTokenEndpoint":"https://p.farhan.codes/oauth/token","sharedInbox":"https://p.farhan.codes/inbox","uploadMedia":"https://p.farhan.codes/api/ap/upload_media"},"followers":"https://p.farhan.codes/users/fedilogue/followers","following":"https://p.farhan.codes/users/fedilogue/following","id":"https://p.farhan.codes/users/fedilogue","inbox":"https://p.farhan.codes/users/fedilogue/inbox","manuallyApprovesFollowers":false,"name":"fedilogue","outbox":"https://p.farhan.codes/users/fedilogue/outbox","preferredUsername":"Fedilogue Mass Follower","publicKey":{"id":"https://p.farhan.codes/users/fedilogue#main-key","owner":"https://p.farhan.codes/users/fedilogue","publicKeyPem":"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAn5JI+uBbt3w0tPekK+UD\naQLRG220XztYLEE1gC8eGYctYgrTX0wruNP+CFap1VsvyWxRoitNjFLDD3pwYxK9\n+k6P459ekL0fSRqQ0bzOQ5Vb22PBs9iOKonV9FSljCcDg0kc3cvxCeU246BMurGI\nIs0vWk3UwygkeMo+rYXDluTtuSvZs+2ume2JYgrtcQoDH5YzU+76dRLYfd1+xEFo\nP+K0hFb7+LhwGwDuLtTUYQ39kqm2jnC9/3W5yyweBqh05iQ0joDC0nuoZpjvT7on\n2Obwluci30Q2xS1i+5244qr9Ouq1EK+9kdf15RMMOH1Azumho1YNFoVZlcxy2bar\n6wIDAQAB\n-----END PUBLIC KEY-----\n\n"},"summary":"","tag":[],"type":"Person","url":"https://p.farhan.codes/users/fedilogue"}
The only difference I see is that the working JSON has spaces between fields, ie "ref":"val"
vs "ref": "val"
.
The headers are as follows: Working:
< HTTP/1.1 200 OK
< Server: nginx/1.18.0
< Date: Mon, 23 Nov 2020 18:08:48 GMT
< Content-Type: application/activity+json; charset=utf-8
< Content-Length: 1623
< Connection: keep-alive
< X-Frame-Options: DENY
< X-Content-Type-Options: nosniff
< HTTP/1.1 200 OK
< Server: nginx/1.18.0
< Date: Mon, 23 Nov 2020 18:08:02 GMT
< Content-Type: application/activity+json; charset=utf-8
< Content-Length: 1584
< Connection: keep-alive
< X-Content-Type-Options: nosniff
< X-Frame-Options: DENY
Is there a way I could investigate this issue? I should add, what I believe is the failure appears to work on Mastodon. Let me know if you want to see the other requests, as my JSON-LD suggestion might be an accidental misdirection.