`orb` does not properly handle `vnd...+` clauses in content-type header value
I created a profile file locally and synced, but I don't see my profile in the app. You previously mentioned that the content-type is being set as application/vnd.subconscious.profile+json in the subconscious app, which may be the underlying problem.
This is a bug in how we currently match media types (aka mimes). Basically "vnd...+" clauses will throw us off and prevent us from detecting file extension/mime relationships correctly.
Copying over from Discord for posterity:
I've been going pretty deep on media types in the last few days. One thing that has come up for me is that although there is theoretically a pattern for us to deterministically/losslessly round-trip between a domain-specific content type and a file extension, it's not going to generalize to the broader universe of media types. And, this presents a challenge when e.g., rendering Noosphere content as a file system view.
Consider as an example this (non-standard) accounting of media types and their "common" file extensions: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
We have basic cases e.g.,
application/xml -> .xml. Fair enough. Now let's be Apple and make a vendor tree version of it for some domain-specific XML:application/vnd.apple.installer+xml -> .mpkgIn other words, the file extension is practically a convention and not deterministically derivable from the mime.
So, we "solve" file extension inference by using a giant map of media types to their plausible file extensions (sourced from third party). And, for things that are domain-specific Subconscious / Noosphere, we have a secondary map that handles things we know about.
Now, the Subconscious profile is a plain text file containing serialized JSON. If I'm a user of
orbI can create a such a file. After filling out its contents, I would save it to disk with the.jsonfile extension. Now, when I go to save it to my sphere,orbinfers theapplication/jsonmedia type. And, this is the problem: we cannot infer from a generic, low-information file extension like.jsonthat the media type we actually should save the file with isapplication/vnd.subconscious+json.There are only two possible changes that I can think of to enable the
orbuser to do the right thing:
- Give them a way to tweak the
content-typeheader manually- Use a specialized file extension for
application/vnd.subconscious+jsonOption 1 is arguably something we should be able to do eventually, but it's extra work and unintuitive as a baseline UX. Option 2 seems more coherent/orthodox to me: every webserver I know of infers the media type from a file extension by default, and if you only have a handful of characters to convey the appropriate media type, there has to be a direct mapping between a file extension and a media type.
So, my recommendation at this point is to do one of the following:
- Use
Content-Type: application/jsonfor the Subconscious_profile_content ...or...- Choose a specialized file extension for
application/vnd.subconcious+json, andorbwill use that when rendering_profile_to the file system
In the end, a decision was made:
Given the conversation above, my sense is that we should update profile to use JSON-LD.
This change will be implemented in Subconscious, and so the "fix" should trickle down to orb users from there.