Profile preference 404 error/ admin profile not work

What does this mean?

Are you using any plugins?

Do you see anything in /logs ?

2 Likes

i disabled all the plugin and restore the database with same error, i don’t have any idea… and this is why i write here.

You’ll need to give us some information to work with.

2 Likes

logs shows this

Job exception: getaddrinfo: No address associated with hostname
2:11 am
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/free
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/application_controller.rb:510:in `render_json_dump'
app/controllers/users_controller.rb:97: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/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

Have you tried to disable badges and see if that resolves the situation?

Yes, I try but same issue

This seems to be the same issue as you posted before. I’ll link the other topic here in case there’s more info in there that can help people figure out what’s gone wrong:

I’m not sure I’m following this 100%. Is the issue that you can’t access the admin screen?

Yes I mention before that I did have this issue month before and try many ways to fix it but everything failed.

Admin screen I can see but I cannot open admin profile, or preference it’s give me 404 error.

And you think this maybe because of some custom badges? Are other users with the custom badges affected? If so, could you revoke the custom badges, or delete them entirely?

Idk how to revoke them or delete them… Is there any guide for that to give a try ?

You can edit/revoke a user’s badges from their admin/user page: (if you can access that one)

Or you can delete a custom badge from the Badges section of the admin area:

[YourSite]/admin/badges

In prefence or profile i cannot access ( 404 error ); and in badge section (500 error);

Error code: 500 error

Maybe i can perfom restore basic badge from database command line ?

Message

Uncaught [object Object]
Url: https://site.com/assets/vendor-3c473d73e5222f7710764282fcc17d73997b7fbd37e0c12afc050b80693ceee2.js
Line: 36
Column: 180628
Window Location: https://site.com/admin/badges

Backtrace



Env

HTTP HOSTS: site.com

I don’t think there’s an easy ‘reset’ you can do for the Badges, even from the rails console.

How far did you get with the Data Explorer query recommended in the other topic? Have you managed to track down which badge image is causing the issue?

No i didn’t, if possible you can have a look ?

After a bit of experimenting, I can replicate this glitch (or possibly something similar). I tried using the console to insert a “null” value in the image_upload_id in the Badge table, and it filled it with 0 instead. That locked up my test site in a very similar way to what you’ve described.

I ‘fixed’ it by changing all the image_upload_id to ‘1’. That allowed me back into my profile and the Badges section, but I now have to manually swop all the badges back to icon only, etc.

To check if yours is a similar problem can you access your data-explorer and create a new query and paste this in (and run):

Select name, image_upload_id
FROM badges b
Order By id desc

I have also figured out that it wants ‘nil’ not ‘null’ in the console to work properly. :slightly_smiling_face:

This fixed my broken ones without needing to go through them all manually:

Badge.where('image_upload_id=0').find_each do |b|
b.image_upload_id = nil
b.save
end

Without knowing exactly what the issue with yours is, I can’t say for sure that will fix yours in the same way - though maybe a ‘change all to nil’ could work for you?

1 Like

Hi @jammydodger,

Well it’s show me something like this

I see most of the badge NULL expect 3 badges have value 17

and after i check the profile again; error still again in the “logs”;

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/application_controller.rb:510:in `render_json_dump'
app/controllers/users_controller.rb:97:in `block (2 levels) in show'
app/controllers/users_controller.rb:89:in `show'
app/controllers/users_controller.rb:103:in `show_card'
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/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

Should i select something else or maybe you prefer to have a look inside with yourself ?

1 Like

The data explorer query won’t fix the issue, but the information it has given may. :+1:

If you’re happy using the rails console you could try the following to reset those 17s to null: (don’t forget to take a back up just in case)

Navigate to the rails console:

cd /var/discourse 
./launcher enter app
rails c

Paste this:

Badge.where('image_upload_id=17').find_each do |b|
b.image_upload_id = nil
b.save
end

And hopefully that will unlock the Badge section and profile so you can start afresh. :+1::crossed_fingers:

2 Likes

Knowledge has no value unless you use it and share it dude! apprecaite your time bro… fixed!

2 Likes

That’s great. :+1::partying_face: Glad I could help. :slightly_smiling_face:

3 Likes