{"record":{"id":"a7b5a3474e73f472","repo":"multica-ai/multica","slug":"state-marker-is-not-a-regular-file-s","errorCode":null,"errorMessage":"state marker is not a regular file: %s","messagePattern":"state marker is not a regular file: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/internal/daemon/execenv/hermes_home.go","lineNumber":578,"sourceCode":"\t\t}\n\t\tif err := os.RemoveAll(filepath.Join(hermesHome, name)); err != nil {\n\t\t\treturn fmt.Errorf(\"reconcile stale %s: %w\", name, err)\n\t\t}\n\t}\n\treturn nil\n}\n\n// prepareHermesTaskLocalState migrates an overlay built by an older daemon away\n// from the shared Hermes SQLite session store. Without the marker, state.db and\n// its sidecars may be symlinks or independently copied files; neither is safe to\n// reuse as task-local state. Remove only those entries inside the generated\n// overlay, then record the migration atomically. Hermes lazily creates a fresh\n// database, and later prepares preserve it because the marker is present.\nfunc prepareHermesTaskLocalState(hermesHome string) error {\n\tmarker := filepath.Join(hermesHome, hermesTaskLocalStateMarker)\n\tif fi, err := os.Lstat(marker); err == nil {\n\t\tif !fi.Mode().IsRegular() {\n\t\t\treturn fmt.Errorf(\"state marker is not a regular file: %s\", marker)\n\t\t}\n\t\treturn nil\n\t} else if !os.IsNotExist(err) {\n\t\treturn fmt.Errorf(\"stat state marker: %w\", err)\n\t}\n\n\tentries, err := os.ReadDir(hermesHome)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"read overlay home: %w\", err)\n\t}\n\tfor _, entry := range entries {\n\t\tif !isHermesTaskLocalStateEntry(entry.Name()) {\n\t\t\tcontinue\n\t\t}\n\t\tpath := filepath.Join(hermesHome, entry.Name())\n\t\tif err := os.RemoveAll(path); err != nil {\n\t\t\treturn fmt.Errorf(\"remove legacy task state %s: %w\", path, err)\n\t\t}","sourceCodeStart":560,"sourceCodeEnd":596,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/internal/daemon/execenv/hermes_home.go#L560-L596","documentation":"prepareHermesTaskLocalState found the task-local-state marker file inside the overlay, but Lstat says it is not a regular file (a directory, symlink, fifo, etc.). The marker records that state.db has been migrated to task-local storage; a non-regular marker means the overlay is corrupt or was tampered with, and the migration logic cannot trust it.","triggerScenarios":"Something replaced .hermes marker file inside env RootDir/hermes-home with a directory or symlink — manual fiddling with the overlay, a broken restore/sync tool, or an old daemon that created it with a different shape.","commonSituations":"Users hand-editing the overlay home; backup/restore tools that materialize symlinks for small files; partial rsync of the env dir that turned the marker into something else.","solutions":["Inspect the marker path printed in the error: `ls -la <hermesHome>/<marker>` and remove the non-regular entry.","Simplest fix: delete the whole generated overlay dir — it is rebuilt from the shared home on next prepare.","Keep external tools (backup, sync, editors) away from generated env overlay directories.","After cleanup, rerun the task and confirm prepare succeeds and a fresh regular marker appears."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"marker := filepath.Join(hermesHome, hermesTaskLocalStateMarker)\nif fi, err := os.Lstat(marker); err == nil && !fi.Mode().IsRegular() {\n\t// corrupt marker: drop the regenerable overlay rather than failing\n\tif err := os.RemoveAll(hermesHome); err != nil { return err }\n}","typeGuard":null,"tryCatchPattern":"if err := prepareHermesTaskLocalState(hermesHome); err != nil {\n\tif strings.Contains(err.Error(), \"state marker is not a regular file\") {\n\t\t_ = os.RemoveAll(hermesHome) // fully regenerable; next prepare rebuilds\n\t\treturn prepareHermesTaskLocalState(hermesHome)\n\t}\n\treturn err\n}","preventionTips":["Never hand-edit or restore-into generated overlay directories.","Exclude env roots from backup/sync tools that alter file types.","If restoring from backup, delete the overlay dir and let it rebuild."],"tags":["filesystem","hermes","execenv","corruption","marker-file"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}