Skip to content

createDiffHTML API fails with "Not a changeset: undefined" #6847

@aribn

Description

@aribn

Description

I'm encountering a 500 Internal Server Error when calling the createDiffHTML API endpoint. Regardless of the startRev and endRev specified, the function fails with the error:

[ERROR] API - Error: Not a changeset: undefined
  at PadDiff._createDiffAtext (/run/etherpad-lite/src/node/utils/padDiff.ts:182:15)
  at applyToAText (/run/etherpad-lite/src/static/js/Changeset.ts:1061:9)
  at applyToText (/run/etherpad-lite/src/static/js/Changeset.ts:405:20)
  at async <anonymous> (/run/etherpad-lite/src/node/hooks/express/openapi.ts:679:22)
  at async Object.exports.createDiffHTML (/run/etherpad-lite/src/node/db/API.ts:855:16)
  at async OpenAPIBackend.handleRequest (/run/etherpad-lite/node_modules/.pnpm/[email protected]/node_modules/openapi-backend/src/7)
  at async PadDiff.getHtml (/run/etherpad-lite/src/node/utils/padDiff.ts:194:19)
  at async handler (/run/etherpad-lite/src/node/hooks/express/openapi.ts:633:20)
  at error (/run/etherpad-lite/src/static/js/Changeset.ts:64:13)
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at unpack (/run/etherpad-lite/src/static/js/Changeset.ts:363:44)

Notably, this even happens if the startRev and endRev are the same.

This suggests that Etherpad is failing to retrieve or process an expected changeset, even though individual revision changesets are retrievable.

Steps to Reproduce

  1. Create a new pad.
  2. Make a few edits to create multiple revisions.
  3. Call the API with:
    GET /api/1.3.0/createDiffHTML?padID=<padID>&startRev=1&endRev=1&apikey=<API_KEY>
  4. The API returns 500 Internal Server Error with "Not a changeset: undefined".
  5. Additionally, createDiffHTML(1,2) and createDiffHTML(1,10) fail, while individual revision changesets (getRevisionChangeset) return correctly.

Expected Behavior

createDiffHTML(1,1) should return valid diff HTML (even if it's an empty or minimal diff).
createDiffHTML(1,2) should successfully compute a diff between the first two revisions.

Actual Behavior

The API call fails with "Not a changeset: undefined".
Etherpad logs show an error originating from Changeset.ts, indicating it is unable to apply or retrieve an expected changeset.

Server (please complete the following information):

  • Etherpad version: 2.2.7
  • API Version: 1.3.0
  • OS: Ubuntu 22.04.5 LTS
  • Node.js version (node --version): v20.18.0
  • npm version (npm --version): 10.8.2
  • Is the server free of plugins: No.

Troubleshooting Done

✅ Verified individual revision changesets (getRevisionChangeset) are retrievable.
✅ Tested smaller revision ranges (createDiffHTML(1,5), createDiffHTML(1,1)) — still fails.
✅ Tested on brand new pads — still fails.
✅ Checked the Etherpad GitHub issues (no existing issue found).

Potential Causes

  • Bug in createDiffHTML Logic?
  • Changeset Processing Bug: Etherpad might fail to apply early changesets correctly.
  • Revision 0 Issue: The initial changeset might not be properly interpreted when computing diffs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    StaleNo recent activity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions