{"record":{"id":"cf9296b2ea459694","repo":"hyperledger/fabric","slug":"s-already-exists-in-s-choose-a-different-locati","errorCode":null,"errorMessage":"%s already exists in %s. Choose a different location or remove the existing results. Aborting identifytxs","messagePattern":"(.+?) already exists in (.+?)\\. Choose a different location or remove the existing results\\. Aborting identifytxs","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/ledgerutil/identifytxs/identifytxs.go","lineNumber":60,"sourceCode":"\tvar records *models.DiffRecordList\n\trecords, err := jsonrw.LoadRecords(recPath)\n\tif err != nil {\n\t\treturn 0, 0, err\n\t}\n\tif len(records.DiffRecords) == 0 {\n\t\treturn 0, 0, errors.Errorf(\"no records were read. JSON record list is either empty or not properly formatted. Aborting identifytxs\")\n\t}\n\n\t// Output directory creation\n\toutputDirName := fmt.Sprintf(\"%s_identified_transactions\", records.Ledgerid)\n\toutputDirPath := filepath.Join(outputDirLoc, outputDirName)\n\n\tempty, err := fileutil.CreateDirIfMissing(outputDirPath)\n\tif err != nil {\n\t\treturn 0, 0, err\n\t}\n\tif !empty {\n\t\treturn 0, 0, errors.Errorf(\"%s already exists in %s. Choose a different location or remove the existing results. Aborting identifytxs\", outputDirName, outputDirLoc)\n\t}\n\n\t// Get recordsMap from json\n\tinputKeyMapWrapper, err := generateRecordsMap(records.DiffRecords, outputDirPath)\n\tif err != nil {\n\t\treturn 0, 0, err\n\t}\n\n\t// Set up block store and block iterator in preparation for traversal\n\tblockStoreProvider, err := getBlockStoreProvider(fsPath)\n\tif err != nil {\n\t\treturn 0, 0, err\n\t}\n\tdefer blockStoreProvider.Close()\n\n\tblockStoreExists, err := blockStoreProvider.Exists(records.Ledgerid)\n\tif err != nil {\n\t\treturn 0, 0, err","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/ledgerutil/identifytxs/identifytxs.go#L42-L78","documentation":"IdentifyTxs writes results into a directory named '<ledgerid>_identified_transactions' under the given output location. CreateDirIfMissing reports whether the directory already existed and was non-empty; if it does, the tool refuses to overwrite prior results and returns this error.","triggerScenarios":"Running ledgerutil identifytxs twice with the same output directory location and the same ledger id, without clearing or renaming the previous results directory.","commonSituations":"Re-running the tool after a failed/partial run; scripted reruns with identical outputDirLoc; two runs targeting the same ledger name in the same output directory.","solutions":["Remove or move the existing '<ledgerid>_identified_transactions' directory, then rerun","Pass a different outputDirLoc on the command line","If it's leftovers from a failed run, verify contents then delete before retrying"],"exampleFix":"// before\nledgerutil identifytxs ./diff.json ./out\n// after (previous run present)\nrm -rf ./out/myledger_identified_transactions\nledgerutil identifytxs ./diff.json ./out","handlingStrategy":"validation","validationCode":"// Go: ensure the output dir does not already exist (non-empty) before running\noutputDir := filepath.Join(outputDirLoc, ledgerid+\"_identified_transactions\")\nif entries, err := os.ReadDir(outputDir); err == nil && len(entries) > 0 {\n    return fmt.Errorf(\"output directory %s already exists and is not empty\", outputDir)\n}","typeGuard":null,"tryCatchPattern":"if _, _, err := ledgerutil.IdentifyTxs(recPath, outDir); err != nil {\n    if strings.Contains(err.Error(), \"already exists\") {\n        return fmt.Errorf(\"move/remove %s or choose a new output dir: %w\", err, err)\n    }\n    return err\n}","preventionTips":["Use a timestamped or unique output directory per run","Clean up results from failed runs before rerunning","Script the removal of <ledgerid>_identified_transactions before automated reruns"],"tags":["hyperledger-fabric","ledgerutil","output-conflict","filesystem"],"backgroundTag":"output-directory-already-exists","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}