umbraco / Umbraco.Deploy.Issues

1 stars 0 forks source link

Custom Property Validation - Length issue #218

Closed AaronSadlerUK closed 3 months ago

AaronSadlerUK commented 3 months ago

When creating document types locally, SQLite does not enforce a maximum length on the custom regex field. What this means in practice is that a regex which works locally will cause deploy to fail due to SQL throwing a truncated exception.

Reproduction

Create a document type Apply the following regex: ^(https?:\\/\\/)?((www|m)\\.)?(youtube\\.com\\/(watch\\?v=|embed\\/|v\\/)|youtu\\.be\\/|youtube\\.[a-z]{2,3}\\/(watch\\?v=|embed\\/|v\\/)|youtube-nocookie\\.com\\/(embed\\/)|vimeo\\.com\\/(channels\\/[A-Za-z0-9]+\\/videos\\/|groups\\/[A-Za-z0-9]+\\/videos\\/|video\\/)|vimeo\\.[a-z]{2,3}\\/(channels\\/[A-Za-z0-9]+\\/videos\\/|groups\\/[A-Za-z0-9]+\\/videos\\/|video\\/))([A-Za-z0-9_-]+)(\\?[A-Za-z0-9=&_-]*)?$ Deploy to cloud from local Deploy will fail to deploy, however it will not log a useful error, the log will say that the data type is missing rather than the regex being longer that 255

Expected result

Deploy should log an error saying that the regex is longer than 255 chars and needs to be shortened

Actual result

Deploy will fail to deploy, however it will not log a useful error, the log will say that the data type is missing rather than the regex being longer that 255

AndyButland commented 3 months ago

I've had a look at this one, and can replicate, but I think Deploy is doing what it should be doing here and if any action is taken on this it should be in other repos.

To replicate I just took one of the .uda files for a document type and manually edited it to add the regex you've supplied. When I trigger a deploy operation to "Update Umbraco Schema From Data Files" from the backoffice, I get this result:

image

Clicking on "View details" reveals the error:

{
  "Date": "2024-06-03T06:36:31.3092239+02:00",
  "Message": "String or binary data would be truncated in table 'UmbracoCmsDeployLiveV10.dbo.cmsPropertyType', column 'validationRegExp'. Truncated value: '^(https?:\\/\\/)?((www|m)\\.)?(youtube\\.com\\/(watch\\?v=|embed\\/|v\\/)|youtu\\.be\\/|youtube\\.[a-z]{2,3}\\/('.\r\nThe statement has been terminated.",
  ...

So perhaps not as user friendly as it could be, but it's fairly clear what the problem is.

And not the error you say - "the log will say that the data type is missing rather than the regex being longer that 255" so it sounds like something else caused a problem before you hit the issue being discussed here.

If this isn't revealed when deploying from local to Cloud then it should be raised on the Cloud issue tracker. But I've tested this and it seems OK - I do a git push with a similar modified .uda file and see this in the portal:

image

Seems to me there should be validation at the CMS though. Even if using SQL Server locally, the only error you get isn't "friendly" and it comes from the database:

image

I was going to raise this on the CMS tracker but it I can see you have already done so, so I'll just link it here: https://github.com/umbraco/Umbraco-CMS/issues/16368