atproto explorer pdsls.dev
atproto tool

Union not accepted as type #10

closed
opened by willem.dobs.nl

The following lexicon is not accepted as valid

{
    "lexicon": 1,
    "id": "org.example.test",
    "defs": {
        "main": {
            "type": "record",
            "key":"tid",
            "record": {
                "type": "object",                
                "properties": {
                    "test":{
                        "type":"ref",
                        "ref":"#generic"
                    }
                }
            }
        },
        "generic": {
            "type": "union",
            "refs": [
                "#concrete1",
                "#concrete2"
            ],
            "closed":true
        },
        "concrete1": {
            "type": "object",
            "required":["p1"],
            "properties": {
                "p1": {
                    "type": "string"
                }
            }
        },
        "concrete2": {
            "type": "object",
            "properties": {
                "p1": {
                    "type": "string"
                }
            }
        }
    }
}

In the console i get the following message

invalid_literal at .defs.generic.type (expected "record", "query", "procedure", "subscription", "object", "array", "token", "bytes", "cid-link", "blob", "boolean", "integer", "string" or "unknown")

If i validate a record using this with goat it correctly validates

According to the reference implementation, this isn't valid: https://github.com/bluesky-social/atproto/blob/1e49025331c8743d1ef4057d71fbae32ffacf3c5/packages/lexicon/src/types.ts#L330

ref and union cannot be valid types in top-level definitions to avoid ambiguity

Is this not only the case for main ( a primary type)?

main can be a non-primary type, but primary types should always have the name "main"

sign up or login to add to the discussion
Labels

None yet.

assignee

None yet.

Participants 2
AT URI
at://did:plc:q3enoeuha5b2zx4p4atxtb7x/sh.tangled.repo.issue/3m3fcoatl3p22