Unprocessable Entity when migrating links with target _blank in structured text

Hi,

I’m in the process of moving a structured text field from one model to an other. It throws an error when migrating links with target _blank applied to it.

Error:
"#/children/0: failed schema #/definitions/Root/properties/children/items: No subschema in \"anyOf\" matched."

"failing_value": {
          "schema": "dast",
          "document": {
            "children": [
              {
                "children": [
                  {
                    "type": "span",
                    "value": "This is a link "
                  },
                  {
                    "children": [
                      {
                        "type": "span",
                        "value": "test"
                      }
                    ],
                    "meta": [
                      {
                        "value": "_blank"
                      }
                    ],
                    "type": "link",
                    "url": "https://www.google.com"
                  }
                ],
                "type": "paragraph"
              }
            ],
            "type": "root"
          }
        },
        "locale": "en-US"
      }
    }

When listing the item i would expect the meta to be similar to this:
{ "id": "target", "value": "_blank" }

The 'id" seems to be missing. Is this a bug or am i doing something wrong?

Hello @mark

The value for this field should be

{
  "data": {
    "structuredText": {
      "structuredText": {
        "value": {
          "schema": "dast",
          "document": {
            "type": "root",
            "children": [
              {
                "type": "paragraph",
                "children": [
                  {
                    "type": "span",
                    "value": "This is a "
                  },
                  {
                    "url": "https://www.google.com/",
                    "meta": [
                      {
                        "id": "target",
                        "value": "_blank"
                      }
                    ],
                    "type": "link",
                    "children": [
                      {
                        "type": "span",
                        "value": "link"
                      }
                    ]
                  }
                ]
              }
            ]
          }
        }
      }
    }
  }
}

Are you still getting errors when trying to use this value?

No i don’t. But i have to transform all Dast documents first:

document = document.replaceAll(
      '{"value":"_blank"}',
      '{"value":"_blank", "id": "target"}',
    );

    document = document.replaceAll(
      '{"value":"noopener"}',
      '{"value":"noopener", "id": "rel"}',
    );

I expected the client.items.list to not return incomplete Dast documents.

@mark , it really shouldn’t return an invalid structured text body, can you link us the record that is returning that body at support@datocms.com so we can take a look at it?

Thank you!