{"record":{"id":"1606863d86d5548a","repo":"chenhg5/cc-connect","slug":"ensure-project-w","errorCode":null,"errorMessage":"ensure project: %w","messagePattern":"ensure project: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/cc-connect/main.go","lineNumber":1126,"sourceCode":"\t\t\tmgmtSrv.SetTimerScheduler(timerSched)\n\t\t}\n\t\tmgmtSrv.SetHeartbeatScheduler(heartbeatSched)\n\t\tif bridgeSrv != nil {\n\t\t\tmgmtSrv.SetBridgeServer(bridgeSrv)\n\t\t}\n\t\tmgmtSrv.SetSetupFeishuSave(func(req core.FeishuSetupSaveRequest) error {\n\t\t\tplatType := req.PlatformType\n\t\t\tif platType == \"\" {\n\t\t\t\tplatType = \"feishu\"\n\t\t\t}\n\t\t\t_, err := config.EnsureProjectWithFeishuPlatform(config.EnsureProjectWithFeishuOptions{\n\t\t\t\tProjectName:  req.ProjectName,\n\t\t\t\tPlatformType: platType,\n\t\t\t\tWorkDir:      req.WorkDir,\n\t\t\t\tAgentType:    req.AgentType,\n\t\t\t})\n\t\t\tif err != nil {\n\t\t\t\treturn fmt.Errorf(\"ensure project: %w\", err)\n\t\t\t}\n\t\t\t_, err = config.SaveFeishuPlatformCredentials(config.FeishuCredentialUpdateOptions{\n\t\t\t\tProjectName:       req.ProjectName,\n\t\t\t\tPlatformType:      platType,\n\t\t\t\tAppID:             req.AppID,\n\t\t\t\tAppSecret:         req.AppSecret,\n\t\t\t\tOwnerOpenID:       req.OwnerOpenID,\n\t\t\t\tSetAllowFromEmpty: true,\n\t\t\t})\n\t\t\treturn err\n\t\t})\n\t\tmgmtSrv.SetSetupWeixinSave(func(req core.WeixinSetupSaveRequest) error {\n\t\t\t_, err := config.EnsureProjectWithWeixinPlatform(config.EnsureProjectWithWeixinOptions{\n\t\t\t\tProjectName: req.ProjectName,\n\t\t\t\tWorkDir:     req.WorkDir,\n\t\t\t\tAgentType:   req.AgentType,\n\t\t\t})\n\t\t\tif err != nil {","sourceCodeStart":1108,"sourceCodeEnd":1144,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/cmd/cc-connect/main.go#L1108-L1144","documentation":"During an interactive registration/setup request handling, an EnsureProject-style call (creating a project record with name, platform type, workdir, agent type) failed, and the error is wrapped as \"ensure project: %w\". This is a propagated upstream error — the root cause is inside the wrapped error, not the wrapper itself.","triggerScenarios":"The registration flow in main.go calls the project-ensuring API with req.ProjectName/PlatformType/WorkDir/AgentType and receives an error (e.g. invalid workdir, duplicate project, underlying persistence failure).","commonSituations":"WorkDir does not exist or is not absolute; a project with the same name already exists; the underlying config/persistence layer failed; invalid agent type string in the request.","solutions":["Read the wrapped root cause after \"ensure project:\" in the error chain — fix that first.","Verify req.WorkDir exists and is a directory before invoking the flow.","Check whether a project with req.ProjectName already exists and use a unique name.","Validate AgentType/PlatformType values against registered agents/platforms."],"exampleFix":"// before\nEnsureProject(...ProjectName: req.ProjectName, WorkDir: req.WorkDir...)\n// after\nif st, err := os.Stat(req.WorkDir); err != nil || !st.IsDir() {\n    return fmt.Errorf(\"workdir does not exist: %s\", req.WorkDir)\n}\nEnsureProject(...)","handlingStrategy":"validation","validationCode":"if st, err := os.Stat(req.WorkDir); err != nil || !st.IsDir() {\n    return fmt.Errorf(\"workdir invalid: %s\", req.WorkDir)\n}\nif req.ProjectName == \"\" || req.AgentType == \"\" {\n    return fmt.Errorf(\"project name and agent type are required\")\n}","typeGuard":null,"tryCatchPattern":"if err := EnsureProject(EnsureProjectOptions{...}); err != nil {\n    return fmt.Errorf(\"ensure project: %w\", err) // inspect chained cause with errors.Unwrap\n}","preventionTips":["Always validate WorkDir exists and is a directory before the flow.","Uniqueness-check ProjectName before registration.","Unwrap the error chain (errors.Unwrap / %v of cause) to find the real failure."],"tags":["project","registration","config","cli"],"backgroundTag":"invalid-config-value","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}