{"record":{"id":"f484034737beb88e","repo":"dgtlmoon/changedetection.io","slug":"migration-failed-len-missing-watch-files-missi","errorCode":null,"errorMessage":"Migration failed: {len(missing)} watch files missing: {missing[:5]}... url-watches.json remains intact, safe to retry.","messagePattern":"Migration failed: (.+?) watch files missing: (.+?)\\.\\.\\. url-watches\\.json remains intact, safe to retry\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"changedetectionio/store/updates.py","lineNumber":617,"sourceCode":"                logger.error(f\"Failed to save watch {uuid}: {e}\")\n                raise Exception(\n                    f\"Migration failed: Could not save watch {uuid}. \"\n                    f\"url-watches.json remains intact, safe to retry. Error: {e}\"\n                )\n\n        logger.critical(f\"Phase 1 complete: Saved {saved_count} watches\")\n\n        # Phase 2: Verify all files exist\n        logger.critical(\"Phase 2/4: Verifying all watch.json files were created...\")\n\n        missing = []\n        for uuid in self.data['watching'].keys():\n            watch_json = os.path.join(self.datastore_path, uuid, \"watch.json\")\n            if not os.path.isfile(watch_json):\n                missing.append(uuid)\n\n        if missing:\n            raise Exception(\n                f\"Migration failed: {len(missing)} watch files missing: {missing[:5]}... \"\n                f\"url-watches.json remains intact, safe to retry.\"\n            )\n\n        logger.critical(f\"Phase 2 complete: Verified {watch_count} watch files\")\n\n        # Phase 3: Create new settings file\n        logger.critical(\"Phase 3/4: Creating changedetection.json...\")\n\n        try:\n            self._save_settings()\n        except Exception as e:\n            logger.error(f\"Failed to create changedetection.json: {e}\")\n            raise Exception(\n                f\"Migration failed: Could not create changedetection.json. \"\n                f\"url-watches.json remains intact, safe to retry. Error: {e}\"\n            )\n","sourceCodeStart":599,"sourceCodeEnd":635,"githubUrl":"https://github.com/dgtlmoon/changedetection.io/blob/5d9c7c6da76340597243e8163c4f2439237fa0e8/changedetectionio/store/updates.py#L599-L635","documentation":"A generic Exception raised in Phase 2 of migrate_legacy_db_format: after saving each watch, the migration verifies that <datastore>/<uuid>/watch.json exists for every uuid in url-watches.json. If any are missing it aborts, listing up to five offending uuids, with url-watches.json again left intact for a safe retry.","triggerScenarios":"Phase 1 reported success (or was interrupted) but one or more watch.json files are absent on disk — typically a process killed mid-migration, disk full causing silent write failures, or filesystem sync issues on network volumes.","commonSituations":"Container OOM-killed or restarted during a large migration; NFS/bind-mount caching hiding freshly written files; antivirus or sync tools (dropbox-style) deleting/moving new files; disk-full during Phase 1.","solutions":["Check disk space and permissions, then simply restart the app — the migration is designed to be re-run","Inspect the listed uuid directories: create/restore the missing watch.json or remove those uuids from url-watches.json if the watches are disposable","Disable aggressive sync/AV on the datastore volume","Back up the whole datastore dir (and url-watches.json) before retrying"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"# pre-migration: verify the datastore dir is writable and has space\nimport shutil\nassert shutil.disk_usage(datastore_path).free > len(watching) * 64 * 1024  # rough headroom","typeGuard":null,"tryCatchPattern":"try:\n    update_26(datastore)\nexcept Exception as e:\n    if 'watch files missing' in str(e):\n        time.sleep(30); restart_app()  # migration is idempotent and safe to retry","preventionTips":["Avoid restarting/OOM-killing the container during a migration window","Disable file sync/AV tooling on the datastore volume","Keep the datastore on local disk rather than flaky network mounts during upgrades"],"tags":["migration","verification","missing-file","datastore"],"backgroundTag":"database-migration-failed","analyzedSha":"5d9c7c6da76340597243e8163c4f2439237fa0e8","analyzedAt":"2026-08-27T19:41:16.067Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}