{"record":{"id":"c5af101025baf0b2","repo":"sansan0/TrendRadar","slug":"error-c5af10","errorCode":null,"errorMessage":"数据一致性检查失败：保存后立即读取失败","messagePattern":"数据一致性检查失败：保存后立即读取失败","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"critical","filePath":"trendradar/__main__.py","lineNumber":1488,"sourceCode":"                    filter_words,\n                    historical_id_to_name,\n                    failed_ids=failed_ids,\n                    global_filters=global_filters,\n                    rss_items=rss_items,\n                    rss_new_items=rss_new_items,\n                    standalone_data=standalone_data,\n                    schedule=schedule,\n                    rss_new_urls=rss_new_urls,\n                )\n\n                combined_id_to_name = {**historical_id_to_name, **id_to_name}\n                new_titles = historical_new_titles\n                id_to_name = combined_id_to_name\n                title_info = historical_title_info\n                results = all_results\n            else:\n                print(\"❌ 严重错误：无法读取刚保存的数据文件\")\n                raise RuntimeError(\"数据一致性检查失败：保存后立即读取失败\")\n        elif self.report_mode == \"daily\":\n            # daily 模式：使用全天累计数据\n            analysis_data = self._load_analysis_data()\n            if analysis_data:\n                (\n                    all_results,\n                    historical_id_to_name,\n                    historical_title_info,\n                    historical_new_titles,\n                    _,\n                    _,\n                    _,\n                ) = analysis_data\n\n                # 使用历史数据准备独立展示区数据（包含完整的 title_info）\n                standalone_data = self._prepare_standalone_data(\n                    all_results, historical_id_to_name, historical_title_info, raw_rss_items\n                )","sourceCodeStart":1470,"sourceCodeEnd":1506,"githubUrl":"https://github.com/sansan0/TrendRadar/blob/8ee26026ba6c11dec41a95fb3895a7162876caa1/trendradar/__main__.py#L1470-L1506","documentation":"Raised by trendradar's main pipeline after it saves a data file and immediately fails to read it back. This is a self-check (write-then-read consistency guard): the save path reported success but the subsequent load returned nothing usable, so the run aborts with RuntimeError rather than silently continuing with missing historical data.","triggerScenarios":"Running trendradar in an on-demand/merged report mode where results are persisted and then reloaded within the same run; the reload returns falsy/none. Causes include the file being written to a different path than read (cwd change between save and load), an external process locking/removing the file, disk-full producing a truncated file, or a save function returning success without flushing.","commonSituations":"Running the CLI from a different working directory so relative data paths diverge; antivirus/sync tools (Dropbox, OneDrive) touching the file between write and read; near-full disk; concurrent trendradar instances writing the same data file.","solutions":["Check disk space and permissions on the data directory; a truncated write is the most common cause.","Run trendradar from a consistent working directory (or set the relevant path env vars absolutely) so save and load resolve the same file.","Ensure only one trendradar instance runs against the same data directory.","Exclude the data directory from sync/antivirus scanning, then rerun.","If it persists, inspect the save function's flush/fsync logic — the file may not be committed before the read."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"data_path = Path(os.environ.get(\"TRENDRADAR_DATA_DIR\", \"data\"))\nif not data_path.is_dir() or os.access(data_path, os.W_OK | os.R_OK):\n    # writable check\n    if not (data_path.is_dir() and os.access(data_path, os.W_OK)):\n        raise OSError(f\"data dir not writable: {data_path}\")\n# also verify free space\nimport shutil\nif shutil.disk_usage(data_path).free < 50 * 1024 * 1024:\n    raise OSError(\"less than 50MB free\")","typeGuard":null,"tryCatchPattern":"for attempt in range(2):\n    try:\n        run_trendradar()\n        break\n    except RuntimeError as e:\n        if \"数据一致性检查失败\" in str(e) and attempt == 0:\n            continue  # one retry: transient fs/sync interference\n        raise","preventionTips":["Run trendradar from a fixed working directory with absolute data paths.","Keep the data directory out of sync/AV scans and free of concurrent writers.","Monitor disk space before scheduled runs."],"tags":["runtime","io","data-integrity","consistency-check"],"backgroundTag":null,"analyzedSha":"8ee26026ba6c11dec41a95fb3895a7162876caa1","analyzedAt":"2026-08-15T01:42:18.084Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}