Fix ckb export EEXIST failures by using per-range subdirectories - #121
Draft
Xcodes-chain with Copilot wants to merge 2 commits into
Draft
Fix ckb export EEXIST failures by using per-range subdirectories#121Xcodes-chain with Copilot wants to merge 2 commits into
Xcodes-chain with Copilot wants to merge 2 commits into
Conversation
…errors Co-authored-by: 15168316096 <45781590+15168316096@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix failing CI integration tests for ckb export command
Fix ckb export EEXIST failures by using per-range subdirectories
Mar 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ckb exportrefuses to write into a non-empty directory (EEXIST, errno 17). All export tests shared a singleexport/directory, causing cascading failures across 8 of 11 tests once the first export populated it.Changes
_export_blocks(from, to)now targetsexport/{from}-{to}/instead of the sharedexport/dir — each call gets a clean directoryckb-{from}-{to}.jsonlisn't found, glob-discovers the single.jsonlin the range dir and renames it to the expected name — handles anyckb exportnaming variationsFileNotFoundErrororRuntimeErrorwhen the export produces zero or multiple.jsonlfiles, instead of silently returning a nonexistent pathtimeimport; fixed implicit f-string concatenation intest_10Original prompt
Problem
The CI integration tests in
test_cases/ckb_command/test_export_import.pyare failing with 8 out of 11 tests broken. The failing job logs: https://github.com/cryptape/ckb-py-integration-test/actions/runs/22847094649Root Cause
The
ckb exportcommand refuses to export when the target directory already contains files, throwing:The
_export_blocks()helper method exports all ranges to the same sharedexport/directory. Whentest_01exports blocks 1-50, it creates a file inexport/. Whentest_02tries to export blocks 1-10 to the same directory,ckb exportsees the existing file and fails withEEXIST. This cascades to all subsequent tests.Two failure modes observed
Export tests (test_01, test_02, test_03): The export command fails or the expected output filename
ckb-{from}-{to}.jsonldoesn't match whatckb exportactually generates, resulting inFileNotFoundError/AssertionError: File not found.Import tests (test_05, test_07, test_08, test_09, test_10): These call
_export_blocks(1, 50)again. Since the expected file doesn't exist (wrong name or previous failure), the cache check (if os.path.exists(expected)) fails, and it tries to re-export into the already-populated directory, triggeringEEXIST.Required Fix
Modify the
_export_blocks()method intest_cases/ckb_command/test_export_import.pyto use a separate subdirectory per block range for each export operation. This avoids theEEXISTconflict because eachckb exportcall gets its own clean target directory.Current code (lines 60-69):
Should be changed to use a per-range subdirectory:
Additionally, if
ckb exportgenerates a file with a different naming convention thanckb-{from}-{to}.jsonl, the method should discover the actual output file. Add a fallback usingglobto find the exported.jsonlfile in the range directory and rename/return it:Only the file
test_cases/ckb_command/test_export_import.pyneeds to be changed. The_export_blocksmethod is the only place that needs modification.The following is the prior conversation context from the user's chat exploration (may be truncated):
User: 帮我分析一下这个报错,解决一下这个问题
Assistant: ## 分析报告
问题根因
这次 CI 失败的 核心原因 是:
ckb export命令在导出时,目标目录(export/)中已经存在同名文件,导致报错:这个错误是 Linux 系统错误码
EEXIST (17),意味着ckb export不支持覆盖已有文件,而测试代码中多个测试方法尝试导出相同 block 范围到同一个目录。失败分为两类
第 1 类:前 3 个 export 测试(test_01、test_02、test_03)
这些测试调用
_export_blocks()进行导出,但导出命令本身静默失败了(exit code 非 0 抛出异常被忽略了,或者第一次就已经失败)。导出文件没有被成功创建,后续断言找不到文件:关键线索:
_export_blocks()方法里有一个短路逻辑: