{"record":{"id":"a6c7223ca1b74676","repo":"xpzouying/xiaohongshu-mcp","slug":"v","errorCode":null,"errorMessage":"视频文件不存在或不可访问: %v","messagePattern":"视频文件不存在或不可访问: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service.go","lineNumber":301,"sourceCode":"\t\treturn err\n\t}\n\n\treturn action.Publish(ctx, content)\n}\n\n// PublishVideo 发布视频（本地文件）\nfunc (s *XiaohongshuService) PublishVideo(ctx context.Context, req *PublishVideoRequest) (*PublishVideoResponse, error) {\n\t// 标题长度校验（小红书限制：最大20个字）\n\tif xhsutil.CalcTitleLength(req.Title) > 20 {\n\t\treturn nil, fmt.Errorf(\"标题长度超过限制\")\n\t}\n\n\t// 本地视频文件校验\n\tif req.Video == \"\" {\n\t\treturn nil, fmt.Errorf(\"必须提供本地视频文件\")\n\t}\n\tif _, err := os.Stat(req.Video); err != nil {\n\t\treturn nil, fmt.Errorf(\"视频文件不存在或不可访问: %v\", err)\n\t}\n\n\tvar scheduleTime *time.Time\n\tif req.ScheduleAt != \"\" {\n\t\tt, err := time.Parse(time.RFC3339, req.ScheduleAt)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"定时发布时间格式错误，请使用 ISO8601 格式: %v\", err)\n\t\t}\n\n\t\t// 校验定时发布时间范围：1小时至14天\n\t\tnow := time.Now()\n\t\tminTime := now.Add(1 * time.Hour)\n\t\tmaxTime := now.Add(14 * 24 * time.Hour)\n\n\t\tif t.Before(minTime) {\n\t\t\treturn nil, fmt.Errorf(\"定时发布时间必须至少在1小时后，当前设置: %s，最早可选: %s\",\n\t\t\t\tt.Format(\"2006-01-02 15:04\"), minTime.Format(\"2006-01-02 15:04\"))\n\t\t}","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/xpzouying/xiaohongshu-mcp/blob/332d196854a9eac0d2b8c2c0e3d0cc43139d724c/service.go#L283-L319","documentation":"After checking non-emptiness, PublishVideo calls os.Stat(req.Video); if that fails (file missing, permission denied, broken symlink), the error is wrapped and returned as '视频文件不存在或不可访问: %v'. The wrapped %v contains the underlying os.Stat error (e.g. 'no such file or directory').","triggerScenarios":"Calling PublishVideo with req.Video pointing to a path that does not exist, is inaccessible due to permissions, or is a broken symlink — anything for which os.Stat returns an error.","commonSituations":"Relative path resolved from a different working directory; file deleted between recording and publishing; container volumes not mounted; running as a different user without read permission.","solutions":["Verify the file exists with os.Stat(req.Video) and log the resolved absolute path before calling PublishVideo","Use an absolute path to avoid working-directory mismatch, especially inside containers/Docker","Check file permissions (chmod/chown) so the process user can read the file","Confirm volume mounts if running in Docker"],"exampleFix":"// before\nreq.Video = \"videos/clip.mp4\" // relative, fails if CWD differs\n// after\nabs, err := filepath.Abs(\"videos/clip.mp4\")\nif err != nil { return err }\nif _, err := os.Stat(abs); err != nil { return fmt.Errorf(\"video missing: %w\", err) }\nreq.Video = abs","handlingStrategy":"validation","validationCode":"if fi, err := os.Stat(req.Video); err != nil {\n    return fmt.Errorf(\"video file not accessible: %w\", err)\n} else if fi.IsDir() {\n    return fmt.Errorf(\"Video must be a file, got a directory: %s\", req.Video)\n}","typeGuard":"func videoFileExists(p string) bool {\n    fi, err := os.Stat(p)\n    return err == nil && !fi.IsDir()\n}","tryCatchPattern":"resp, err := svc.PublishVideo(ctx, req)\nif err != nil && strings.Contains(err.Error(), \"视频文件不存在或不可访问\") {\n    return fmt.Errorf(\"check path/permissions for %s: %w\", req.Video, err)\n}","preventionTips":["Convert to and log absolute paths (filepath.Abs) before publishing","os.Stat the video right before the call to catch races/deletions","In containers, verify volume mounts and the process user's read permission","Check the wrapped os.Stat error text: 'no such file' vs 'permission denied' point to different fixes"],"tags":["go","filesystem","video","file-not-found"],"backgroundTag":"file-not-found","analyzedSha":"332d196854a9eac0d2b8c2c0e3d0cc43139d724c","analyzedAt":"2026-09-05T22:22:55.988Z","contentChangedAt":"2026-09-05T22:22:55.988Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}