payloadcms / payloadcms/payload
Bug in HTML to lexical conversion with image reference.
@AlessioGr is already working on this.
Since Jul 16, 2026.
- Dominant language
- TypeScript
- Stars
- 44.8k
- Forks
- 4.2k
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 53
Description
Describe the Bug
When using code similar to the documentation at https://payloadcms.com/docs/rich-text/converting-html#approach-1-pre-upload-images-and-use-data-attributes-recommended , creating new richtext values programmatically to insert into the database referencing an image - The convertHTMLToLexical function incorrectly parses the HTML data-lexical-upload-id as a string, meaning the validation fails, and the item cannot be inserted.
This bug (presumably) only affects database configurations using an integer key type.
Full bug details, example, workaround and instructions in the linked repo.
Link to the code that reproduces this issue
https://github.com/stephenirven/payload-convert-html-bug-reproduce
Reproduction Steps
- Requires a database set to use an integer key type. Example uses postgres.
- Provide postgres details in .env as usual.
- Clone the repo, install as usual, run pnpm dev, create the first user as usual
- Upload an image to the media collection, which will be given id: 1
- Click the link from the dashboard to the endpoint that runs the example code.
- Instructions and details are on the dashboard.
Which area(s) are affected?
area: core
Environment Info
Binaries:
Node: 24.11.0
npm: 11.6.1
Yarn: 1.22.22
pnpm: 10.2.1
Relevant Packages:
payload: 3.86.0
next: 16.2.6
@payloadcms/db-postgres: 3.86.0
@payloadcms/drizzle: 3.86.0
@payloadcms/graphql: 3.86.0
@payloadcms/next/utilities: 3.86.0
@payloadcms/richtext-lexical: 3.86.0
@payloadcms/translations: 3.86.0
@payloadcms/ui/shared: 3.86.0
react: 19.2.6
react-dom: 19.2.6
Operating System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 25.5.0: Tue Jun 9 22:26:46 PDT 2026; root:xnu-12377.121.10~1/RELEASE_ARM64_T8103
Available memory (MB): 16384
Available CPU cores: 8
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.