discourse(prod)> # Replace with the topic ID or URL you’re debugging
discourse(prod)> topic_id = 386983
discourse(prod)>
discourse(prod)> # 1. Check if TopicEmbed exists and its content
discourse(prod)> te = TopicEmbed.find_by(topic_id: topic_id)
discourse(prod)> puts “TopicEmbed exists: #{te.present?}”
discourse(prod)> puts “Embed URL: #{te&.embed_url}”
discourse(prod)> puts “Content cache present: #{te&.embed_content_cache.present?}”
discourse(prod)> puts “Content cache length: #{te&.embed_content_cache&.length || 0}”
discourse(prod)> puts “Content SHA1: #{te&.content_sha1}”
discourse(prod)>
discourse(prod)> # 2. Check the actual cached content (first 500 chars)
discourse(prod)> puts “\n— Cached content preview —”
discourse(prod)> puts te&.embed_content_cache&.truncate(500)
discourse(prod)>
discourse(prod)> # 3. Try fetching from the remote URL
discourse(prod)* if te&.embed_url.present?
discourse(prod)* puts “\n— Attempting remote fetch —”
discourse(prod)* begin
discourse(prod)* response = TopicEmbed.find_remote(te.embed_url)
discourse(prod)* puts “Remote fetch success: #{response.present?}”
discourse(prod)* puts “Remote body present: #{response&.body.present?}”
discourse(prod)* puts “Remote body length: #{response&.body&.length || 0}”
discourse(prod)* puts “Remote title: #{response&.title}”
discourse(prod)* puts “Remote body: #{response&.body&.truncate(500)}”
discourse(prod)* rescue => e
discourse(prod)* puts “Remote fetch FAILED: #{e.message}”
discourse(prod)* end
discourse(prod)> end
discourse(prod)>
discourse(prod)> # 4. Check what expanded_for would return
discourse(prod)* if te.present?
discourse(prod)* puts “\n— Testing expanded_for —”
discourse(prod)* post = Post.find(te.post_id)
discourse(prod)*
discourse(prod)* # Clear cache to force fresh fetch
discourse(prod)* Discourse.cache.delete(“embed-topic:#{topic_id}”)
discourse(prod)*
discourse(prod)* begin
discourse(prod)* expanded = TopicEmbed.expanded_for(post)
discourse(prod)* puts “Expanded content present: #{expanded.present?}”
discourse(prod)* puts “Expanded content length: #{expanded&.length || 0}”
discourse(prod)* rescue => e
discourse(prod)* puts “expanded_for FAILED: #{e.message}”
discourse(prod)* end
discourse(prod)> end
discourse(prod)>
discourse(prod)> # 5. Check relevant settings
discourse(prod)> puts “\n— Site Settings —”
discourse(prod)> puts “embed_truncate: #{SiteSetting.embed_truncate}”
discourse(prod)> puts “allowed_embed_selectors: #{SiteSetting.allowed_embed_selectors}”
discourse(prod)> puts “blocked_embed_selectors: #{SiteSetting.blocked_embed_selectors}”
TopicEmbed exists: false
Embed URL:
Content cache present: false
Content cache length: 0
Content SHA1:
— Cached content preview —
— Site Settings —
embed_truncate: true
allowed_embed_selectors:
blocked_embed_selectors:
=> nil
discourse(prod)>

1 Like