Badge image missing issue

Hello,

I have issue with badge section, i have modified some badges and add some images there; after 6 months i restore a backup and everything works fine execpt the badge section; i try to login with safe-mode and disable all plugins… but issue still same, how can i restore the badge sections withd default name and images ?

error show me

Message (2 copies reported)

NoMethodError (undefined method `url' for nil:NilClass)
app/models/badge.rb:306:in `image_url'
(eval):10:in `_fast_attributes'
app/controllers/application_controller.rb:484:in `serialize_data'
app/controllers/badges_controller.rb:30:in `index'
app/controllers/application_controller.rb:387:in `block in with_resolved_locale'
app/controllers/application_controller.rb:387:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:71:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:356:in `call'
config/initializers/100-quiet_logger.rb:23:in `call'
config/initializers/100-silence_logger.rb:31:in `call'
lib/middleware/enforce_hostname.rb:23:in `call'
lib/middleware/request_tracker.rb:198:in `call'

Backtrace

app/models/badge.rb:306:in `image_url'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:99:in `block in attribute'
(eval):10:in `_fast_attributes'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:468:in `rescue in attributes'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:455:in `attributes'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:480:in `_serializable_hash'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:359:in `serializable_hash'
active_model_serializers (0.8.4) lib/active_model/array_serializer.rb:89:in `block in _serializable_array'
active_model_serializers (0.8.4) lib/active_model/array_serializer.rb:79:in `map'
active_model_serializers (0.8.4) lib/active_model/array_serializer.rb:79:in `_serializable_array'

Env

HTTP HOSTS: site.com
1 Like

Other images were restored correctly?

Did you make sure to include uploads in the backup?
backup_options

Are you using s3 to store your uploads? If not, could you enter the container, and go to /shared/uploads/default/original/1X do you have files there?

1 Like

yes i don’t use s3, and i always use to include attachment pictures in backup…

what i’m looking for now how to make reset for badge images ??

Out of the box, there is no way to “make reset for badge images” that I know of.

What I’d do first is check that the badges missing images were at least restored. If you check the badges table you can get the ID of the image at the image_upload field. Then use that ID in the uploads table, to get the URL of the image, like so:

select url from uploads where id = <badge-upload-id>

The URL looks something like this: /uploads/default/original/1X/c1325294cd04ae6e9072a2577543dad66cf31afe.jpeg and from there, you can extract the name of the file, in this case it would be c1325294cd04ae6e9072a2577543dad66cf31afe.jpeg

Then you can check in the server that the image is there with find or whatever method you prefer

cd /
find . -name c1325294cd04ae6e9072a2577543dad66cf31afe.jpeg

Once you made sure the images were restored, at the right path, then you can continue debugging as the issue is somewhere else.

The version of Discourse from the backup is too different from the version of Discourse you are restoring into?

Maybe someone else in the community knows more about this, though.

1 Like

Perfect, but how can i know the missing badge url or name ?

I cannot find how i know the missing url or badge image name.

Follow the instruction here Data Explorer Plugin to install the data explorer plugin, you can use it to inspect the badges table. Focus on your custom badges.

1 Like

I did install it; but i didn’t find the badge table;

this is the error i get when i open the profile of administrator;

Message

NoMethodError (undefined method `url' for nil:NilClass)
app/models/badge.rb:306:in `image_url'
(eval):10:in `_fast_attributes'
lib/freedom_patches/ams_include_without_root.rb:54:in `include!'
lib/freedom_patches/ams_include_without_root.rb:54:in `include!'
app/controllers/users_controller.rb:92:in `block (2 levels) in show'
app/controllers/users_controller.rb:89:in `show'
app/controllers/application_controller.rb:387:in `block in with_resolved_locale'
app/controllers/application_controller.rb:387:in `with_resolved_locale'
lib/middleware/omniauth_bypass_middleware.rb:71:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:356:in `call'
config/initializers/100-quiet_logger.rb:23:in `call'
config/initializers/100-silence_logger.rb:31:in `call'
lib/middleware/enforce_hostname.rb:23:in `call'
lib/middleware/request_tracker.rb:198:in `call'

Backtrace

app/models/badge.rb:306:in `image_url'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:99:in `block in attribute'
(eval):10:in `_fast_attributes'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:468:in `rescue in attributes'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:455:in `attributes'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:480:in `_serializable_hash'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:359:in `serializable_hash'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:448:in `block in merge_association'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:445:in `each'
active_model_serializers (0.8.4) lib/active_model/serializer.rb:445:in `merge_association'

Env

HTTP HOSTS: site.com