{"record":{"id":"4ad9c1da84fccfdf","repo":"gastownhall/beads","slug":"resolveproxiedinit-read-config-w","errorCode":null,"errorMessage":"ResolveProxiedInit: read config: %w","messagePattern":"ResolveProxiedInit: read config: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/storage/domain/beads.go","lineNumber":142,"sourceCode":"}\n\nvar _ BeadsDirFSUseCase = (*beadsDirFSUseCaseImpl)(nil)\n\nfunc (u *beadsDirFSUseCaseImpl) ResolveBeadsDir(ctx context.Context) BeadsDirResolution {\n\treturn u.fsRepo.ResolveBeadsDirPath(ctx)\n}\n\nfunc (u *beadsDirFSUseCaseImpl) ResolveProxiedInit(ctx context.Context, params ResolveProxiedInitParams) (ResolveProxiedInitResult, error) {\n\tresolution := u.fsRepo.ResolveBeadsDirPath(ctx)\n\tresult := ResolveProxiedInitResult{\n\t\tBeadsDir:    resolution.BeadsDir,\n\t\tHasExplicit: resolution.HasExplicit,\n\t\tIsLocal:     u.fsRepo.BeadsDirIsLocal(ctx),\n\t}\n\n\tcfg, err := u.fsRepo.ReadBeadsConfig(ctx)\n\tif err != nil {\n\t\treturn ResolveProxiedInitResult{}, fmt.Errorf(\"ResolveProxiedInit: read config: %w\", err)\n\t}\n\n\tresult.DBName, result.DBNameDerived = resolveDoltDatabaseName(cfg, params.Prefix, params.DBFlag)\n\tresult.ProjectID = resolveProjectID(cfg)\n\treturn result, nil\n}\n\nfunc resolveDoltDatabaseName(cfg *configfile.Config, prefix, dbFlag string) (name string, derived bool) {\n\tif dbFlag != \"\" {\n\t\treturn dbFlag, false\n\t}\n\tif cfg != nil && cfg.DoltDatabase != \"\" {\n\t\treturn cfg.DoltDatabase, false\n\t}\n\tif prefix != \"\" {\n\t\treturn strings.ReplaceAll(prefix, \"-\", \"_\"), true\n\t}\n\treturn configfile.DefaultDoltDatabase, true","sourceCodeStart":124,"sourceCodeEnd":160,"githubUrl":"https://github.com/gastownhall/beads/blob/71377f276968b452ee607177637970a4ff888584/internal/storage/domain/beads.go#L124-L160","documentation":"ResolveProxiedInit reads the beads config file (fsRepo.ReadBeadsConfig) to resolve the Dolt database name and project ID. When reading that config fails — missing file when required, unreadable, or malformed — the error is wrapped with this prefix and returned. Initialization cannot proceed without the config.","triggerScenarios":"Calling ResolveProxiedInit in a directory where ReadBeadsConfig fails: the beads config file is absent, lacks read permissions, is corrupt/invalid YAML/JSON, or the filesystem access errors (e.g. network mount down).","commonSituations":"Running an init/resolve command outside an initialized beads workspace; config file deleted or partially written; permission changes after checkout; config syntax broken by a manual edit or merge conflict.","solutions":["Read the wrapped inner error to identify the exact cause (not-found vs parse vs permission).","Verify the beads config file exists at the expected location and re-run beads init if the workspace was never initialized.","If the config exists, validate its syntax — fix corruption or merge-conflict markers, or restore it from git.","Check file permissions on the config and its parent directories."],"exampleFix":"// before: running in a dir with no/corrupt config\nresult, err := u.ResolveProxiedInit(ctx, params) // ResolveProxiedInit: read config: open .beads/config.yaml: no such file\n// after\nif _, statErr := os.Stat(configPath); os.IsNotExist(statErr) {\n    return fmt.Errorf(\"not a beads workspace; run 'bd init' first\")\n}\nresult, err := u.ResolveProxiedInit(ctx, params)","handlingStrategy":"validation","validationCode":"if _, err := os.Stat(configPath); err != nil {\n    return fmt.Errorf(\"beads config not found at %s; run 'bd init': %w\", configPath, err)\n}\nresult, err := useCase.ResolveProxiedInit(ctx, params)","typeGuard":null,"tryCatchPattern":"result, err := useCase.ResolveProxiedInit(ctx, params)\nif err != nil {\n    if strings.Contains(err.Error(), \"read config\") {\n        if errors.Is(err, fs.ErrNotExist) { /* re-init workspace */ }\n        if errors.Is(err, fs.ErrPermission) { /* fix permissions */ }\n    }\n    return err\n}","preventionTips":["Verify the workspace is initialized (config file exists) before calling ResolveProxiedInit.","Keep the beads config under version control so corruption can be reverted.","Do not hand-edit the config without validating syntax afterward.","Check read permissions on the config and parent directories after environment changes."],"tags":["config","filesystem","init"],"backgroundTag":"config-read-failed","analyzedSha":"71377f276968b452ee607177637970a4ff888584","analyzedAt":"2026-08-30T18:55:39.744Z","schemaVersion":2},"datasetVersion":"2026-08-30T23:17:21.991Z"}