Backup Restore fails with EXCEPTION: ERROR: value too long for type character varying(1000)

We are using Discourse v3.2.5.

This used to work before however, recently we started seeing issues. Restore from back is failing with the exception EXCEPTION: ERROR: value too long for type character varying(1000) when trying to remap the uploads.

[2025-03-18 21:03:24] Reconnecting to the database…

[2025-03-18 21:03:24] Reloading site settings…

[2025-03-18 21:03:24] Disabling outgoing emails for non-staff users…

[2025-03-18 21:03:25] Disabling readonly mode…

[2025-03-18 21:03:25] Clearing category cache…

[2025-03-18 21:03:25] Reloading translations…

[2025-03-18 21:03:25] Remapping uploads…

[2025-03-18 21:03:27] Remapping with regex from ‘//s3-bucket-name.s3.amazonaws.com/uploads/’ to ‘/uploads/default/’
[2025-03-18 21:03:35] Restoring uploads, this may take a while…
[2025-03-18 21:03:37] EXCEPTION: ERROR: value too long for type character varying(1000)

I was able to fix it by changing the character varying for origin column in uploads table in dump.sql before restore. However, I would like to know how it was working earlier and why it is failing now without any changes in database or application. We see the same error in 3.2.1 and 3.2.5

I found that the Uploads Origin includes the Amazon Metadata that includes security token everytime the object is accessed. and hence the length exceeds 1000. Any reason why the metadata is included in the origin and is updated everytime the file is accessed ?? Can we remove the metadata from origin url? or can we update the character varying constraint from 1000 to 2000 ?

1 Like