jointakahe / takahe

An ActivityPub/Fediverse server
BSD 3-Clause "New" or "Revised" License
1.1k stars 84 forks source link

JsonLdError in canonicalise when AP event contains LD schema not built-in #640

Closed osmaa closed 8 months ago

osmaa commented 10 months ago

Repetitive error in my logs:

('Dereferencing a URL did not result in a valid JSON-LD object. Possible causes are an inaccessible URL perhaps due to a same-origin policy (ensure the server uses CORS if you are using client-side JavaScript), too many redirects, a non-JSON response, or more than one HTTP Link Header was provided for a remote context.',)
Type: jsonld.InvalidUrl
Code: loading remote context failed
Details: {'url': 'https://app.wafrn.net/contexts/litepub-0.1.jsonld', 'cause': JsonLdError("No schema built-in for '*/contexts/litepub-0.1.jsonld'")}
("No schema built-in for '*/contexts/litepub-0.1.jsonld'",)
Type: jsonld.LoadDocumentError
Code: loading document failed
Cause: KeyError  File "/takahe/core/ld.py", line 587, in builtin_document_loader
    return schemas[key]
           ~~~~~~~^^^^^

Changing the built-in schema wildcard for litepub doesn't seem like the right choice for one server placing its schemas in an untypical path. Mastodon loads remote schemas, and if we did too, that'd solve this, as the URL does resolve. However, we don't load remote schemas, and if we did, we probably should have a cache for them.

andrewgodwin commented 10 months ago

Yeah, this was one of the tradeoffs when I made it not do remote queries for schemas; it'll need fixing eventually. I do wonder if we could just strip out unknown schemas for now though, since I doubt we use anything referred to by them.

osmaa commented 10 months ago

okay, I'll just test not raising the error, see what happens.

AstraLuma commented 8 months ago

Was this fixed by #644?

osmaa commented 8 months ago

it was