Skip to content

fix(files_versions): create version entity instead of failing when missing#61202

Open
solracsf wants to merge 1 commit into
masterfrom
fix/files_versions-create-version-entity-on-copy
Open

fix(files_versions): create version entity instead of failing when missing#61202
solracsf wants to merge 1 commit into
masterfrom
fix/files_versions-create-version-entity-on-copy

Conversation

@solracsf

@solracsf solracsf commented Jun 11, 2026

Copy link
Copy Markdown
Member

Summary

A COPY assigns the target a new file id without a version entity, so post_write_hook's updateVersionEntity() raised DoesNotExistException and crashed the request. Handle it in the listener (the caller) by creating the entity for the current content, leaving the backend free to keep throwing.

Error stack
{
  "reqId": "iNwhE8uZnaFbKbyG6WFq",
  "level": 3,
  "time": "2025-09-11T09:48:09+02:00",
  "remoteAddr": "91.6.26.13",
  "user": "fzez",
  "app": "no app in context",
  "method": "COPY",
  "url": "/remote.php/dav/files/user/folder/file.md",
  "message": "Exception thrown: OCP\\AppFramework\\Db\\DoesNotExistException",
  "userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36",
  "version": "30.0.14.1",
  "exception": {
    "Exception": "OCP\\AppFramework\\Db\\DoesNotExistException",
    "Message": "Did expect one result but found none when executing: query \"SELECT * FROM `*PREFIX*files_versions` WHERE (`file_id` = :dcValue1) AND (`timestamp` = :dcValue2)\"; ",
    "Code": 0,
    "Trace": [
      {
        "file": "/var/www/nextcloud/lib/public/AppFramework/Db/QBMapper.php",
        "line": 359,
        "function": "findOneQuery",
        "class": "OCP\\AppFramework\\Db\\QBMapper",
        "type": "->",
        "args": [
          {
            "__class__": "OC\\DB\\QueryBuilder\\QueryBuilder"
          }
        ]
      },
      {
        "file": "/var/www/nextcloud/apps/files_versions/lib/Db/VersionsMapper.php",
        "line": 60,
        "function": "findEntity",
        "class": "OCP\\AppFramework\\Db\\QBMapper",
        "type": "->",
        "args": [
          {
            "__class__": "OC\\DB\\QueryBuilder\\QueryBuilder"
          }
        ]
      },
      {
        "file": "/var/www/nextcloud/apps/files_versions/lib/Versions/LegacyVersionsBackend.php",
        "line": 254,
        "function": "findVersionForFileId",
        "class": "OCA\\Files_Versions\\Db\\VersionsMapper",
        "type": "->",
        "args": [
          204706,
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/nextcloud/apps/files_versions/lib/Versions/VersionManager.php",
        "line": 129,
        "function": "updateVersionEntity",
        "class": "OCA\\Files_Versions\\Versions\\LegacyVersionsBackend",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/nextcloud/apps/files_versions/lib/Listener/FileEventsListener.php",
        "line": 254,
        "function": "updateVersionEntity",
        "class": "OCA\\Files_Versions\\Versions\\VersionManager",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      {
        "file": "/var/www/nextcloud/apps/files_versions/lib/Listener/FileEventsListener.php",
        "line": 85,
        "function": "post_write_hook",
        "class": "OCA\\Files_Versions\\Listener\\FileEventsListener",
        "type": "->",
        "args": [
          "*** sensitive parameters replaced ***"
        ]
      },
      ...
}

Checklist

AI (if applicable)

  • The test of this PR was partly or fully generated using AI

@solracsf solracsf force-pushed the fix/files_versions-create-version-entity-on-copy branch from c929d85 to be2b632 Compare June 11, 2026 11:11
Assisted-by: ClaudeCode:claude-opus-4-8
Signed-off-by: Git'Fellow <12234510+solracsf@users.noreply.github.com>
@solracsf solracsf force-pushed the fix/files_versions-create-version-entity-on-copy branch from be2b632 to d9e7c4c Compare June 11, 2026 11:34
@susnux susnux added the community pull requests from community label Jun 11, 2026
@solracsf solracsf marked this pull request as ready for review June 12, 2026 06:08
@solracsf solracsf requested a review from a team as a code owner June 12, 2026 06:08
@solracsf solracsf requested review from Altahrim, come-nc, leftybournes and salmart-dev and removed request for a team June 12, 2026 06:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3. to review Waiting for reviews AI assisted community pull requests from community feature: versions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants