Shopify Index Page Error ( Not Found ) when update value layout/theme.liquid

Topic summary

A developer is encountering a “Not Found” error when attempting to update the layout/theme.liquid asset in Shopify’s main theme. The error occurs when trying to modify the theme.liquid file to insert Google Tag Manager code before the closing </head> tag.

Technical Details:

  • Error reference ID: 21770abd-c6a1-442e-833a-f32e5536ddcb-1715762926
  • The code retrieves the main theme, finds the existing layout/theme.liquid asset, and attempts to update its value
  • Uses ShopifyAPI classes (Theme and Asset) with an active session context

Current Status:

  • No responses or solutions have been provided yet
  • The issue remains unresolved
  • The code snippet appears partially corrupted or reversed in the original post, which may complicate troubleshooting
Summarized with AI on November 9. AI used: claude-sonnet-4-5-20250929.

Hi Shopify App Store developer,

can help to check what why facing error during update value into key “layout/theme.liquid” ?

error code return :

Shopify Index Page Error : {“errors”:“Not Found”,“error_reference”:“If you report this error, please include this id: 21770abd-c6a1-442e-833a-f32e5536ddcb-1715762926.”}

here is code request :

theme = ShopifyAPI::Theme.all&.find { |t| t.role == “main” }
if theme&.id.present?
asset = ShopifyAPI::Asset.all(theme_id: theme.id, asset: {“key” => “layout/theme.liquid”})&.first
if asset&.value.present?
test_session = ShopifyAPI::Context.active_session
update_asset = ShopifyAPI::Asset.new(session: test_session)
update_asset.theme_id = theme.id
update_asset.key = “layout/theme.liquid”
update_asset.value = asset.value.sub(“”, "

") update_asset.save! end end