Skip to content

Fix null contentRef handling in RecordColumnValue #3566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

conico974
Copy link
Contributor

@conico974 conico974 commented Aug 15, 2025

Improve handling of contentRef to prevent null values and ensure proper resolution in the RecordColumnValue function. Introduce a utility function to validate contentRef objects.

Copy link

linear bot commented Aug 15, 2025

Copy link

changeset-bot bot commented Aug 15, 2025

⚠️ No Changeset found

Latest commit: e2db036

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

argos-ci bot commented Aug 15, 2025

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
customers-v2 (Inspect) 👍 Changes approved 1 changed Aug 20, 2025, 3:54 PM
v2-cloudflare (Inspect) 👍 Changes approved 4 changed Aug 20, 2025, 4:00 PM
v2-vercel (Inspect) ✅ No changes detected - Aug 20, 2025, 3:55 PM

Copy link
Member

@SamyPesse SamyPesse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we are fixing at the right place; I always oppose all changes that go into fixing data problems in places where we should trust the types.
The real problem here is that the API outputs something it should not; let's fix this.

@@ -110,3 +110,7 @@ export function getColumnVerticalAlignment(column: DocumentTableDefinition): Ver

return 'self-center';
}

export function isContentRef(ref: DocumentTableRecord['values'][string]): ref is ContentRef {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum, why do we need this?

We should not have to check types dynamically; the API should return what it says. Otherwise it's a problem on GBX.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Steven already made the change in GBX to the API https://github.com/GitbookIO/gitbook-x/pull/19236.
isContentRef is not necessarily needed, ref can be null | ContentRef

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I think the isContentRef is the good solution here, by nature we can't easily type a Table as it is a user created type.
The type of DocumentTableRecord['values'][string] is string | number | boolean | string[] | ContentRef | null
Not sure if we can type this one that much better without overcomplicating things

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.

3 participants