Overview

Working on creating a content template, I ran into a 500 error when trying to publish it:
assert($field_item_list instanceof FieldItemListInterface)

The field in the content type List (text) field and the filed in the component is a type: string . Is this a known bug, or anyone have any thoughts on this? on Canvas 1.3.3

It fails kind of silently. In the UI will act like it published the page, but it doesn't (the page remains in the queue of changes). The error only shows up in the console, not in the UI.

Proposed resolution

The value of a List (text) field in a content type should be a valid match for a type: string field in an SDC

User interface changes

If this is not meant to be a valid field link, either don't allow the user to link it at all, or display a better error in the UI.

CommentFileSizeAuthor
Screenshot 2026-05-05 at 1.06.38 PM.png108.19 KBkmwarboy

Issue fork canvas-3588520

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

kmwarboy created an issue. See original summary.

shubham.prakash made their first commit to this issue’s fork.

shubham.prakash’s picture

Status: Active » Needs review
wim leers’s picture

Title: Error linking List(text) field in content type to string field in SDC using content template » list_string field type's `label` field property added by Canvas crashes
Component: … to be triaged » Config management
Assigned: Unassigned » wim leers
Status: Needs review » Needs work
Issue tags: +Needs tests
Related issues: +#3548749: Allow mapping "List (string)" field type to `type: string`, with a twist: don't map the stored value, but its key/name/label
wim leers’s picture

Version: 1.3.3 » 1.x-dev
Assigned: wim leers » Unassigned
Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs tests

Interesting analysis, @shubham.prakash, on the MR:

ListStringItemLabel::calculateDependencies() assumed it would always have a full parent chain (field item → field item list → entity), but when the field item is conjured for static dependency calculation (no real entity), the parent is NULL. The fix guards against this by checking if the parent is a FieldItemListInterface and returning an empty array if not.

What was the missing piece for me, was the backtrace: https://git.drupalcode.org/project/canvas/-/merge_requests/1058#note_823232

That allowed me to add a test that proves @shubham.prakash's fixed the original reported bug … but didn't actually fix the root cause 😅 The root cause allowed me to actually just delete some code 🎉

Details: https://git.drupalcode.org/project/canvas/-/merge_requests/1058#note_823269.

wim leers’s picture

Title: list_string field type's `label` field property added by Canvas crashes » list_string field type's `label` field property added by Canvas crashes in `ListStringItemLabel::calculateDependencies()`
Component: Config management » Shape matching

Aligning with the issue queue component that the MR that introduced this bug.

wim leers’s picture

Priority: Normal » Critical

This prevents you from exposing certain information from Canvas!

Critical bug because if you need to use such a field, there is no work-around.

Thanks for the bug report, @kmwarboy, and the initial fix, @shubham.prakash! 🙇🏻‍♂️

wim leers’s picture

Title: list_string field type's `label` field property added by Canvas crashes in `ListStringItemLabel::calculateDependencies()` » list_string field type's `label` field property added by Canvas crashes in `ListStringItemLabel::calculateDependencies()` when linked in a Content Template
wim leers’s picture

Title: list_string field type's `label` field property added by Canvas crashes in `ListStringItemLabel::calculateDependencies()` when linked in a Content Template » `list_string` field type's `label` field property added by Canvas crashes in `ListStringItemLabel::calculateDependencies()` when linked in a Content Template
Issue tags: +AI-accelerated

wim leers’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.