Skip to content

Guard against null content in preparse callback#25

Open
sheldonkotyk wants to merge 2 commits intoStillat:main-v2from
sheldonkotyk:fix/null-content-in-preparse-callback
Open

Guard against null content in preparse callback#25
sheldonkotyk wants to merge 2 commits intoStillat:main-v2from
sheldonkotyk:fix/null-content-in-preparse-callback

Conversation

@sheldonkotyk
Copy link
Contributor

Problem

When Statamic passes null to the preparse callback — for example, when a tag like {{ seo_pro:meta }} returns no value on a 404 page — the AntlersCompiler::compile() method throws a TypeError due to its string type hint:

Stillat\AntlersComponents\AntlersCompiler::compile(): Argument #1 ($content) must be of type string, null given

Fix

Added a guard in the ServiceProvider preparse callback to return non-string values unchanged, allowing the runtime to handle them as it normally would.

Test plan

  • Verify pages with tags that can return null (e.g. on 404 pages) no longer throw a TypeError
  • Verify normal component compilation still works as expected

🤖 Generated with Claude Code

sheldonkotyk and others added 2 commits March 19, 2026 12:22
When Statamic passes null to the preparse callback (e.g. when a tag
returns no value on a 404 page), the compile() method throws a TypeError
due to its string type hint. Guard against non-string values by
returning the content unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@JohnathonKoster
Copy link
Contributor

JohnathonKoster commented Mar 19, 2026

Before you get too far, I'd like to see the dependency updates split off into their own PR to keep the descriptions accurate to the changeset.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants