Skip to content

Regression in 2.1: Unconfigured content properties return _Content object instead of null #445

Description

@rawnanoob

Description

After upgrading from 2.0 to 2.1, unconfigured content properties no longer return null.

In 2.0, if an optional content property was not configured, it returned:

null

In 2.1, the same property now returns:

{
  "__typename": "_Content"
}

This appears to be a behavior change/regression and breaks common null-check logic such as:

{content.video && (
  <section>
    <OptimizelyComponent content={content.video} />
  </section>
)}

Since the returned object is truthy, the component is rendered even though the content property is effectively empty.

Steps to Reproduce

  1. Use SDK/API version 2.1.
  2. Define an optional content property, for example:
video: {
  type: "content" as const,
  displayName: "Video",
  sortOrder: 55,
  isLocalized: true,
  allowedTypes: [EmbeddedVideoContentType],
},
  1. Create a page and leave the video property unconfigured.
  2. Fetch/query the page.
  3. Inspect the value of content.video.

Expected Behavior

An unconfigured optional content property should return:

null

This was the behavior in version 2.0.

Actual Behavior

The property returns:

{
  "__typename": "_Content"
}

instead of null.

Impact

This is a breaking change for applications that rely on null checks to determine whether optional content exists. Existing conditional rendering logic now evaluates to true for unconfigured content properties, requiring additional checks for __typename or other workarounds.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions