{"record":{"id":"1d78d9337bcfb474","repo":"gastownhall/beads","slug":"failed-to-open-s-w","errorCode":null,"errorMessage":"failed to open %s: %w","messagePattern":"failed to open (.+?): %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/molecules/molecules.go","lineNumber":170,"sourceCode":"\t\tSkipPrefixValidation: true, // Molecules use their own prefix\n\t}\n\tif err := l.store.CreateIssuesWithFullOptions(ctx, newMolecules, \"molecules-loader\", opts); err != nil {\n\t\treturn 0, fmt.Errorf(\"batch create molecules: %w\", err)\n\t}\n\treturn len(newMolecules), nil\n}\n\n// loadMoleculesFromFile loads molecules from a JSONL file.\nfunc loadMoleculesFromFile(path string) ([]*types.Issue, error) {\n\t// Check if file exists\n\tif _, err := os.Stat(path); os.IsNotExist(err) {\n\t\treturn nil, nil\n\t}\n\n\t// #nosec G304 - path is constructed from known safe locations\n\tfile, err := os.Open(path)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"failed to open %s: %w\", path, err)\n\t}\n\tdefer file.Close()\n\n\tvar molecules []*types.Issue\n\tscanner := bufio.NewScanner(file)\n\tlineNum := 0\n\n\tfor scanner.Scan() {\n\t\tlineNum++\n\t\tline := scanner.Text()\n\n\t\t// Skip empty lines\n\t\tif strings.TrimSpace(line) == \"\" {\n\t\t\tcontinue\n\t\t}\n\n\t\tvar issue types.Issue\n\t\tif err := json.Unmarshal([]byte(line), &issue); err != nil {","sourceCodeStart":152,"sourceCodeEnd":188,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/molecules/molecules.go#L152-L188","documentation":"loadMoleculesFromFile opens the molecules JSONL file; if os.Open fails, the OS error is wrapped with the path for context. This typically means the file is missing or unreadable.","triggerScenarios":"os.Open(path) returns an error: file doesn't exist, wrong path configured for molecules.jsonl, or permission denied.","commonSituations":"Fresh clone where molecules.jsonl was never generated; typo'd path in configuration; running under a service account lacking read permission; town-level molecules path pointing at a non-existent directory.","solutions":["Check the path in the error exists: ls <path>; regenerate or restore molecules.jsonl if missing.","Fix the configured path/location for town- or project-level molecules files.","Fix filesystem permissions (chmod/chown) so the process user can read the file."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if _, err := os.Stat(path); err != nil {\n    return fmt.Errorf(\"molecules file missing (%s): %w\", path, err)\n}","typeGuard":null,"tryCatchPattern":"molecules, err := loadMoleculesFromFile(path)\nif err != nil {\n    if errors.Is(err, fs.ErrNotExist) {\n        // generate or skip default molecules\n        return nil\n    }\n    return err\n}","preventionTips":["Generate molecules.jsonl before loading","Check file existence/permissions in setup scripts","Run under a user with read access to the data directory"],"tags":["file-io","molecules","missing-file"],"backgroundTag":"file-not-found","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}