ArgumentError (Attributes per element limit exceeded) when trying to open the diff of a locked topic

AI-generated summary

meglio reported an ArgumentError (Attributes per element limit exceeded) error occurring when attempting to view the diff of a locked topic on their self-hosted Discourse instance. The error originates in lib/discourse_diff.rb during the tokenization of HTML blocks, specifically triggered by the PostRevisionSerializer. sam requested a reproduction of the issue, but meglio declined to share the content publicly due to confidentiality regarding a beta product. They agreed to share the content via private message if a reproducible example could be isolated.

Meanwhile, copymonopoly contributed a related report, noting that they experience backend timeouts (502/504) when saving major edits to extremely long posts (around 100,000 characters). They suspect the root cause is the computational expense of calculating diffs between large revisions. Consequently, zogstrip closed this thread, directing the discussion to a separate topic focused on backend timeouts caused by diff bottlenecks in long posts.

ArgumentError (Attributes per element limit exceeded) - when clicking on the “edit” icon to see topic version diffs.

Developer Console

Logs

Message (2 copies reported)

ArgumentError (Attributes per element limit exceeded)
lib/discourse_diff.rb:171:in `tokenize_html_blocks'
lib/discourse_diff.rb:10:in `initialize'
app/serializers/post_revision_serializer.rb:117:in `new'
app/serializers/post_revision_serializer.rb:117:in `body_changes'
(eval):18:in `_fast_attributes'
app/controllers/application_controller.rb:520:in `render_json_dump'
app/controllers/posts_controller.rb:408:in `latest_revision'
app/controllers/application_controller.rb:397:in `block in with_resolved_locale'
app/controllers/application_controller.rb:397: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:187:in `call'

Backtrace

nokogiri-1.12.5-x86_64 (linux) lib/nokogiri/html5/document_fragment.rb:38:in `fragment'
nokogiri-1.12.5-x86_64 (linux) lib/nokogiri/html5/document_fragment.rb:38:in `initialize'
nokogiri-1.12.5-x86_64 (linux) lib/nokogiri/html5/document_fragment.rb:52:in `new'
nokogiri-1.12.5-x86_64 (linux) lib/nokogiri/html5/document_fragment.rb:52:in `parse'
nokogiri-1.12.5-x86_64 (linux) lib/nokogiri/html5.rb:242:in `fragment'
lib/discourse_diff.rb:171:in `tokenize_html_blocks'
lib/discourse_diff.rb:10:in `initialize'
app/serializers/post_revision_serializer.rb:117:in `new'
app/serializers/post_revision_serializer.rb:117:in `body_changes'
(eval):18:in `_fast_attributes'

Env

HTTP HOSTS: jai.community

Is this on the site we host for you? We need to see the diff that causes the pathological behavior.

It’s self-hosted. What would be the best way to share the diff with you?

If there is nothing secret, can you try reproducing here? Just post a reply, then wait 10 minutes and make the problem edit.

It’s not a public community, and the material is regarding a beta product that’s not public either. So with all the respect to both the author of the material and the Discourse team, I’d prefer not to share it here. Any other simple way?

1 Like

I guess divide and conquer? Try making smaller and smaller repros until you find the culprit line?

1 Like

Shell I post the content of that particular topic in a PM to you here in Meta?

Feel free, especially if you can create a repro.

I’m also experiencing a very similar (or related) issue.

Reproduction steps / cause:

  • The problem occurs on extremely long posts (around 100,000 characters).
  • It is triggered specifically by large-scale revisions (when a huge portion of the content is changed).

When trying to save such a massive edit, the backend often hits a timeout (502/504). I suspect the root cause is the Diff calculation between the old and new versions, which becomes extremely expensive under these two conditions combined.

Closing this one as the discussion continues over at