From ad0d976188d1f07401b9675b5c6045c91e82a84e Mon Sep 17 00:00:00 2001 From: bnewbold Date: Wed, 3 Jan 2024 00:24:32 +0100 Subject: [PATCH] lexicons: more string limits (#1994) * limit external embed strings sizes * set a (very large) alt text length limit The motivation is to have *some* size limit on every string in post records, to maximize interoperation. For example, we currently have a CBOR library rejecting some records because of too-long strings. We don't want to limit the ability of folks to be very descriptive in alt text, specifically, so chose what seems to be a very large limit. If this is not large enough, based on feedback, we can bump it even higher. As context this is the largest string length limit in all of our lexicons. * make thumbnail URL fields format=uri This mostly results in checks against the string being empty, or unlimited size. * codegen: string limits * add changeset for string format lex updates --- .changeset/odd-kids-warn.md | 5 +++++ lexicons/app/bsky/embed/external.json | 26 +++++++++++++++++++++----- lexicons/app/bsky/embed/images.json | 16 ++++++++++++---- packages/api/src/client/lexicons.ts | 15 +++++++++++++++ packages/bsky/src/lexicon/lexicons.ts | 15 +++++++++++++++ packages/pds/src/lexicon/lexicons.ts | 15 +++++++++++++++ 6 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 .changeset/odd-kids-warn.md diff --git a/.changeset/odd-kids-warn.md b/.changeset/odd-kids-warn.md new file mode 100644 index 00000000000..021bda81456 --- /dev/null +++ b/.changeset/odd-kids-warn.md @@ -0,0 +1,5 @@ +--- +'@atproto/api': patch +--- + +additional app.bsky.feed.post Lexicon string format limits diff --git a/lexicons/app/bsky/embed/external.json b/lexicons/app/bsky/embed/external.json index 8946382835f..85ef69ea4a2 100644 --- a/lexicons/app/bsky/embed/external.json +++ b/lexicons/app/bsky/embed/external.json @@ -18,8 +18,16 @@ "required": ["uri", "title", "description"], "properties": { "uri": { "type": "string", "format": "uri" }, - "title": { "type": "string" }, - "description": { "type": "string" }, + "title": { + "type": "string", + "maxGraphemes": 300, + "maxLength": 3000 + }, + "description": { + "type": "string", + "maxGraphemes": 1000, + "maxLength": 10000 + }, "thumb": { "type": "blob", "accept": ["image/*"], @@ -42,9 +50,17 @@ "required": ["uri", "title", "description"], "properties": { "uri": { "type": "string", "format": "uri" }, - "title": { "type": "string" }, - "description": { "type": "string" }, - "thumb": { "type": "string" } + "title": { + "type": "string", + "maxGraphemes": 300, + "maxLength": 3000 + }, + "description": { + "type": "string", + "maxGraphemes": 1000, + "maxLength": 10000 + }, + "thumb": { "type": "string", "format": "uri" } } } } diff --git a/lexicons/app/bsky/embed/images.json b/lexicons/app/bsky/embed/images.json index 5baa7ab3f74..48106f62aa1 100644 --- a/lexicons/app/bsky/embed/images.json +++ b/lexicons/app/bsky/embed/images.json @@ -23,7 +23,11 @@ "accept": ["image/*"], "maxSize": 1000000 }, - "alt": { "type": "string" }, + "alt": { + "type": "string", + "maxGraphemes": 5000, + "maxLength": 50000 + }, "aspectRatio": { "type": "ref", "ref": "#aspectRatio" } } }, @@ -51,9 +55,13 @@ "type": "object", "required": ["thumb", "fullsize", "alt"], "properties": { - "thumb": { "type": "string" }, - "fullsize": { "type": "string" }, - "alt": { "type": "string" }, + "thumb": { "type": "string", "format": "uri" }, + "fullsize": { "type": "string", "format": "uri" }, + "alt": { + "type": "string", + "maxGraphemes": 5000, + "maxLength": 50000 + }, "aspectRatio": { "type": "ref", "ref": "#aspectRatio" } } } diff --git a/packages/api/src/client/lexicons.ts b/packages/api/src/client/lexicons.ts index 55de861d600..3d6c725ed18 100644 --- a/packages/api/src/client/lexicons.ts +++ b/packages/api/src/client/lexicons.ts @@ -4744,9 +4744,13 @@ export const schemaDict = { }, title: { type: 'string', + maxGraphemes: 300, + maxLength: 3000, }, description: { type: 'string', + maxGraphemes: 1000, + maxLength: 10000, }, thumb: { type: 'blob', @@ -4775,12 +4779,17 @@ export const schemaDict = { }, title: { type: 'string', + maxGraphemes: 300, + maxLength: 3000, }, description: { type: 'string', + maxGraphemes: 1000, + maxLength: 10000, }, thumb: { type: 'string', + format: 'uri', }, }, }, @@ -4816,6 +4825,8 @@ export const schemaDict = { }, alt: { type: 'string', + maxGraphemes: 5000, + maxLength: 50000, }, aspectRatio: { type: 'ref', @@ -4859,12 +4870,16 @@ export const schemaDict = { properties: { thumb: { type: 'string', + format: 'uri', }, fullsize: { type: 'string', + format: 'uri', }, alt: { type: 'string', + maxGraphemes: 5000, + maxLength: 50000, }, aspectRatio: { type: 'ref', diff --git a/packages/bsky/src/lexicon/lexicons.ts b/packages/bsky/src/lexicon/lexicons.ts index 55de861d600..3d6c725ed18 100644 --- a/packages/bsky/src/lexicon/lexicons.ts +++ b/packages/bsky/src/lexicon/lexicons.ts @@ -4744,9 +4744,13 @@ export const schemaDict = { }, title: { type: 'string', + maxGraphemes: 300, + maxLength: 3000, }, description: { type: 'string', + maxGraphemes: 1000, + maxLength: 10000, }, thumb: { type: 'blob', @@ -4775,12 +4779,17 @@ export const schemaDict = { }, title: { type: 'string', + maxGraphemes: 300, + maxLength: 3000, }, description: { type: 'string', + maxGraphemes: 1000, + maxLength: 10000, }, thumb: { type: 'string', + format: 'uri', }, }, }, @@ -4816,6 +4825,8 @@ export const schemaDict = { }, alt: { type: 'string', + maxGraphemes: 5000, + maxLength: 50000, }, aspectRatio: { type: 'ref', @@ -4859,12 +4870,16 @@ export const schemaDict = { properties: { thumb: { type: 'string', + format: 'uri', }, fullsize: { type: 'string', + format: 'uri', }, alt: { type: 'string', + maxGraphemes: 5000, + maxLength: 50000, }, aspectRatio: { type: 'ref', diff --git a/packages/pds/src/lexicon/lexicons.ts b/packages/pds/src/lexicon/lexicons.ts index 55de861d600..3d6c725ed18 100644 --- a/packages/pds/src/lexicon/lexicons.ts +++ b/packages/pds/src/lexicon/lexicons.ts @@ -4744,9 +4744,13 @@ export const schemaDict = { }, title: { type: 'string', + maxGraphemes: 300, + maxLength: 3000, }, description: { type: 'string', + maxGraphemes: 1000, + maxLength: 10000, }, thumb: { type: 'blob', @@ -4775,12 +4779,17 @@ export const schemaDict = { }, title: { type: 'string', + maxGraphemes: 300, + maxLength: 3000, }, description: { type: 'string', + maxGraphemes: 1000, + maxLength: 10000, }, thumb: { type: 'string', + format: 'uri', }, }, }, @@ -4816,6 +4825,8 @@ export const schemaDict = { }, alt: { type: 'string', + maxGraphemes: 5000, + maxLength: 50000, }, aspectRatio: { type: 'ref', @@ -4859,12 +4870,16 @@ export const schemaDict = { properties: { thumb: { type: 'string', + format: 'uri', }, fullsize: { type: 'string', + format: 'uri', }, alt: { type: 'string', + maxGraphemes: 5000, + maxLength: 50000, }, aspectRatio: { type: 'ref',