Fix Control Panel crash when SEO fields contain invalid Antlers#631
Open
mynetx wants to merge 1 commit into
Open
Fix Control Panel crash when SEO fields contain invalid Antlers#631mynetx wants to merge 1 commit into
mynetx wants to merge 1 commit into
Conversation
The Cascade's two Antlers parse sites only caught the Antlers runtime exception, but errors like ModifierNotFoundException extend the base Exception class and escaped. Since the Cascade runs during fieldtype preload, a bad schema value would 500 both saving and reopening any entry, leaving it uneditable until the file was fixed by hand. Catch all exceptions and fall back to the raw value like the existing guard intended. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When an SEO field value contains Antlers that fails to parse, for example
{{ collection from="locations" }}in the JSON-LD schema field (fromgets treated as a modifier), the resultingModifierNotFoundExceptionescapes the Cascade. Since the Cascade runs during fieldtype preload, this 500s the entry save and, because the invalid value has already been persisted at that point, every subsequent visit to the entry's edit page too. The entry stays uneditable until the file is fixed by hand. Reported in #632.Both parse sites in the Cascade already had a fallback that returns the raw value, but it only caught the Antlers
RuntimeException. Exceptions likeModifierNotFoundExceptionextend the baseExceptionclass and slipped through. This broadens the two catches so any parse failure degrades to the raw value, which is what the guard intended.Note this also applies on the front end: an invalid schema is now emitted raw inside the JSON-LD script tag instead of throwing. Invalid JSON-LD, but consistent with the existing fallback and preferable to a 500.
Related: #629 touches the same field but has a different symptom.
Fixes #632
🤖 Generated with Claude Code