Sketch: Schema validation strictness levels #51
Replies: 3 comments 3 replies
-
On the example, I've reached out to Brian M to get them to use one of the existing location types. In this case it should be |
Beta Was this translation helpful? Give feedback.
-
I think validation modes is a great idea. I propose a few things for consideration:
This is a future problem, but we should prepare for the scenario where a lexicon schema definition is private and cannot be resolved. In those cases, the validation logic wouldn't be able to tell if the type doesn't exist or if it just doesn't have access to it. |
Beta Was this translation helpful? Give feedback.
-
It's me, hi, I'm the problem, it's me I will bikeshed in a slightly different direction than intended - I was surprised that (AFAICT) there aren't client libraries which help use the lexicon correctly when writing code. I initially expected a JS/TS library to help me use these lexicons with some degree of type safety that would have made VSCode / TS highlight my mistake. In the absence of an existing reference implementation to check my usage against, I vibe-coded straight into an invalid type. (I found |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Background
There is a lot of room for interpretation in the atproto spec around when to apply validation to records and at what level of strictness to apply it at. Lexicons are specified to be extensible via a few ways; open unions and object properties come to mind, but there may be others.
Handling open unions
Let's zoom in on a specific example. Imagine we have a record that has an unknown type inside of an open union, like so:
community.lexicon.embed.geo
isn't defined as a type in theembed
union onapp.bsky.feed.post
, which is perfectly valid according to the spec. However there are questions that arise when it comes to resolution and validation of this record:community.lexicon.embed.geo
resolves to a valid type and theembed
value is valid according to that typecommunity.lexicon.embed.geo
resolves to a valid type but theembed
value is invalid according to that typecommunity.lexicon.embed.geo
does not resolve to a valid lexicon typeI'm using "validator" above to refer to validation libraries, CLIs, services, or dev tools like https://atproto-browser.vercel.app or lpm
I suspect the answer lies somewhere within "it depends" territory, and that there are levels of strictness that you may want to use depending on your use case.
The proposal
Define a model of strictness levels ranging from very lax to very strict. This will allow tooling across implementors and programming languages to agree on terminology and behaviour.
This model can be proved out first into tooling within lexicon.community such as lpm, and then potentially upstreamed into atproto specs or guidance.
Strictness model
There is a matrix of different levels with the dimensions of:
I'd suggest we bikeshed names for each level so that eg. APIs in libraries can have a "strictness" setting with well-known semantics. There may be more dimensions that I'm not thinking of right now and not every combination may make sense as a level in the model.
Beta Was this translation helpful? Give feedback.
All reactions