{"record":{"id":"ba024e3084d741f9","repo":"siyuan-note/siyuan","slug":"no-entry","errorCode":null,"errorMessage":"no entry","messagePattern":"no entry","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/model/upload.go","lineNumber":488,"sourceCode":"\t\t\t\ttmpDir2 := filepath.Join(util.TempDir, \"convert\", \"zip\", gulu.Rand.String(7))\n\t\t\t\tif err = gulu.Zip.Unzip(writePath, tmpDir2); err != nil {\n\t\t\t\t\trecordFailure(index, file.Filename, fName, err)\n\t\t\t\t\t_ = os.RemoveAll(tmpDir)\n\t\t\t\t\t_ = os.RemoveAll(tmpDir2)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\n\t\t\t\tentries, readErr := os.ReadDir(tmpDir2)\n\t\t\t\tif nil != readErr {\n\t\t\t\t\tlogging.LogErrorf(\"read dir [%s] failed: %s\", tmpDir2, readErr)\n\t\t\t\t\trecordFailure(index, file.Filename, fName, readErr)\n\t\t\t\t\t_ = os.RemoveAll(tmpDir)\n\t\t\t\t\t_ = os.RemoveAll(tmpDir2)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tif 1 > len(entries) {\n\t\t\t\t\tlogging.LogErrorf(\"read dir [%s] failed: no entry\", tmpDir2)\n\t\t\t\t\tnoEntryErr := errors.New(\"no entry\")\n\t\t\t\t\trecordFailure(index, file.Filename, fName, noEntryErr)\n\t\t\t\t\t_ = os.RemoveAll(tmpDir)\n\t\t\t\t\t_ = os.RemoveAll(tmpDir2)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tdirName := entries[0].Name()\n\t\t\t\tsrcDir := filepath.Join(tmpDir2, dirName)\n\t\t\t\tentries, readErr = os.ReadDir(srcDir)\n\t\t\t\tif nil != readErr {\n\t\t\t\t\tlogging.LogErrorf(\"read dir [%s] failed: %s\", filepath.Join(tmpDir2, entries[0].Name()), readErr)\n\t\t\t\t\trecordFailure(index, file.Filename, fName, readErr)\n\t\t\t\t\t_ = os.RemoveAll(tmpDir)\n\t\t\t\t\t_ = os.RemoveAll(tmpDir2)\n\t\t\t\t\tcontinue\n\t\t\t\t}\n\t\t\t\tdestDir := filepath.Join(assetsDirPath, fName)\n\t\t\t\tif copyErr := copyRTFDEntries(entries, srcDir, destDir, gulu.File.Copy); nil != copyErr {\n\t\t\t\t\tlogging.LogErrorf(\"copy RTFD directory [%s] failed: %s\", srcDir, copyErr)","sourceCodeStart":470,"sourceCodeEnd":506,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/model/upload.go#L470-L506","documentation":"During Upload of a directory-style asset, the kernel extracts the bundle into a temp directory and then reads its entries. If the extracted second-level temp directory (tmpDir2) contains no entries at all, it treats the archive as empty/invalid, logs \"read dir [...] failed: no entry\", records the failure with \"no entry\", and cleans up both temp directories.","triggerScenarios":"Uploading an archive/bundle (needUnzip2Dir path) whose extracted contents are empty or whose structure nests the real files deeper than one directory level, so the single directory the code expects (entries[0]) is missing.","commonSituations":"Corrupted or zero-byte .zip/.rtfd files; bundles zipped with an extra wrapping folder so the expected first entry is not a directory; archives whose payload was stripped by the packaging tool.","solutions":["Verify the uploaded archive is valid and non-empty; re-create and re-upload it.","Ensure the bundle layout matches the expected structure: one top-level directory directly containing the asset files (no extra nesting).","If the asset genuinely has no content, upload individual files instead of an archive."],"exampleFix":"// before\nzip -r note.rtfd.zip note.rtfd/old/   // wrong nesting / empty payload\n// after\nzip -r note.rtfd.zip note.rtfd/       // note.rtfd dir with files inside","handlingStrategy":"validation","validationCode":"func validateBundle(zipPath string) error {\n    zr, err := zip.OpenReader(zipPath)\n    if err != nil { return err }\n    defer zr.Close()\n    if len(zr.File) == 0 { return errors.New(\"archive is empty\") }\n    for _, f := range zr.File {\n        if !f.FileInfo().IsDir() { return nil }\n    }\n    return errors.New(\"archive contains only directories\")\n}","typeGuard":null,"tryCatchPattern":"_, _, failed, err := model.Upload(...)\nfor _, f := range failed {\n    if f.Error == \"no entry\" {\n        logging.LogWarnf(\"archive %s extracted to nothing; verify bundle and retry\", f.Name)\n    }\n}","preventionTips":["Validate archives are non-empty and contain files before uploading.","Keep the bundle layout simple: one top-level directory with the asset files directly inside.","Check archive integrity (e.g. zip -T) when bundles are produced by scripts."],"tags":["archive","empty-directory","upload"],"backgroundTag":"empty-result-set","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}