Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing attribute: published_at after updating to a recent nightly #26229

Closed
renchap opened this issue Jul 28, 2023 · 1 comment · Fixed by #26343
Closed

Missing attribute: published_at after updating to a recent nightly #26229

renchap opened this issue Jul 28, 2023 · 1 comment · Fixed by #26343
Labels
bug Something isn't working status/identified This bug has been identified
Milestone

Comments

@renchap
Copy link
Sponsor Member

renchap commented Jul 28, 2023

Steps to reproduce the problem

When a nightly/main update containing #26153, timeline request result in 500 errors:

ActiveModel::MissingAttributeError (missing attribute: published_at):
app/controllers/api/v1/favourites_controller.rb:10:in `index'
app/controllers/concerns/localized.rb:11:in `set_locale'
lib/mastodon/rack_middleware.rb:9:in `call'
lib/public_file_server_middleware.rb:18:in `call'

ActiveModel::MissingAttributeError (missing attribute: published_at):
app/controllers/api/v1/notifications_controller.rb:17:in `index'
app/controllers/concerns/localized.rb:11:in `set_locale'
lib/mastodon/rack_middleware.rb:9:in `call'

ActiveModel::MissingAttributeError (missing attribute: published_at):
app/controllers/api/v1/trends/statuses_controller.rb:12:in `index'
app/controllers/concerns/localized.rb:11:in `set_locale'
lib/mastodon/rack_middleware.rb:9:in `call'

Expected behaviour

The update does not cause errors

Actual behaviour

We get 500 errors on timelines

Detailed description

Purging the Rails cache fixes the issues, there are most probably items in cache without this new published_at attribute, and rendering those fail until the cache expires.

Mastodon instance

No response

Mastodon version

nightly

Technical details

No response

@renchap renchap added bug Something isn't working status/to triage This issue needs to be triaged labels Jul 28, 2023
@renchap renchap added this to the 4.2.0 milestone Jul 28, 2023
@renchap renchap added status/identified This bug has been identified and removed status/to triage This issue needs to be triaged labels Jul 28, 2023
@ClearlyClaire
Copy link
Contributor

ClearlyClaire commented Jul 28, 2023

Something like the following should fix it, but I wonder if there's a cleaner solution:

diff --git a/app/serializers/rest/preview_card_serializer.rb b/app/serializers/rest/preview_card_serializer.rb
index cf700ff24e..2eb67214c9 100644
--- a/app/serializers/rest/preview_card_serializer.rb
+++ b/app/serializers/rest/preview_card_serializer.rb
@@ -15,4 +15,8 @@ class REST::PreviewCardSerializer < ActiveModel::Serializer
   def html
     Sanitize.fragment(object.html, Sanitize::Config::MASTODON_OEMBED)
   end
+
+  def published_at
+    object.published_at if object.respond_to?(:published_at)
+  end
 end

An alternative is to bump the appropriate cache key (but we need to figure out which ones).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working status/identified This bug has been identified
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants