Unable to restore/update discourse (PG::InvalidTextRepresentation: ERROR: invalid input syntax for type integer: "[]")

Hi !

I have an instance currently running on 2.9.0.beta4, and I needed to migrate it, so I did the basic backup/restore, but restore failed on the new instance. I decided then to try to update the original instance, but it failed also. Both failed, seemingly for the same reason, during the db:migrate command.

Update error : https://pastebin.com/raw/sQrnMe27
Restore error : https://pastebin.com/raw/idWYmEFq

Thanks for the help !

2 Likes

Looks like it may be a :bug:

This looks to me like it’s in core, but the standard question is Do you have any non-standard plugins?

1 Like

No, it’s a vanilla one :slight_smile:

I had a similar error on my test site where I had some errant data in my selectable_avatar site setting, and had to update it through the rails console.

Are you comfortable using the rails console? If so, could you run this and see what it says:

SiteSetting.where(data_type:17)

4 Likes

I’m not sure if I’ve done it correctly, but here is what I get :

=> #<ActiveRecord::Relation [#<SiteSetting id: 56, name: "selectable_avatars", data_type: 17, value: "[]", created_at: "2022-06-07 04:30:35.458837000 +0000", updated_at: "2022-06-08 08:14:54.196037000 +0000">]>

2 Likes

I think you should be able to run SiteSetting.selectable_avatars = "" (from the rails console again), and then be good for a rebuild.

6 Likes

Currently, rebuilding and just passed the stressful db migrate command, so I guess this one is fixed.
Thank you both of you for your quick help !

2 Likes

Looks like you did it! You should see if you can get attention to this, as I’m pretty sure that migration is supposed to migrate those selectable avatars to the new format.

2 Likes

It is, and it’s worked in every other case we’ve seen. [] isn’t a valid value, even in the old format, so this particular case is quite surprising. Maybe it’s left over from some manual work on the console, or a bad import :thinking:

If we get more reports, we’ll be sure to add an automated fix for this case.

2 Likes

Ah. Right. Usually when I get that error, it’s becuase I messed up such that I was accessing the wrong variable or something. But maybe that was the state that it was left in after all of the other ones had been deleted. But, really, I wasn’t paying close enough attention. :wink:

1 Like

Our ‘list’ settings are a thin UI over pipe-delimited strings, so in theory an empty list should be stored as an empty string. But you make a good point - maybe someone was trying to empty the list and did something like this by accident:

pry(main)> SiteSetting.selectable_avatars = []
=> []
pry(main)> SiteSetting.selectable_avatars
=> "[]"

(this is with the old format. The new format has validations to prevent this, even on the console)

1 Like

Well in our case, the forum was set up at the beginning of this month, and no interactions with the console whatsoever (nor imports). In fact, I’ve discovered rails console today :smile:

2 Likes