{"record":{"id":"d132d7c0a4c3d495","repo":"larksuite/cli","slug":"s-w-d132d7","errorCode":null,"errorMessage":"@%s: %w","messagePattern":"@%s: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"shortcuts/slides/slides_create.go","lineNumber":420,"sourceCode":"// presentation and returns the path→file_token map. The second return value is\n// the number of files successfully uploaded before any error, so callers can\n// surface progress in the failure message. param names the flag the XML came\n// from, so an error points at the flag the caller actually typed.\nfunc uploadSlidesPlaceholders(runtime *common.RuntimeContext, presentationID string, paths []string, param string) (map[string]string, int, error) {\n\ttokens := make(map[string]string, len(paths))\n\tfor i, path := range paths {\n\t\tstat, err := runtime.FileIO().Stat(path)\n\t\tif err != nil {\n\t\t\treturn tokens, i, slidesInputStatError(err, param, fmt.Sprintf(\"@%s\", path))\n\t\t}\n\t\tif !stat.Mode().IsRegular() {\n\t\t\treturn tokens, i, errs.NewValidationError(errs.SubtypeInvalidArgument, \"@%s: must be a regular file\", path).WithParam(param)\n\t\t}\n\t\tfileName := filepath.Base(path)\n\n\t\ttoken, err := uploadSlidesMedia(runtime, path, fileName, stat.Size(), presentationID)\n\t\tif err != nil {\n\t\t\treturn tokens, i, fmt.Errorf(\"@%s: %w\", path, err) //nolint:forbidigo // intermediate; preserves typed cause via %w, reclassified by appendSlidesProgressHint at the call site\n\t\t}\n\t\ttokens[path] = token\n\t}\n\treturn tokens, len(paths), nil\n}\n\n// xmlEscape escapes special XML characters in text content.\nfunc xmlEscape(s string) string {\n\ts = strings.ReplaceAll(s, \"&\", \"&amp;\")\n\ts = strings.ReplaceAll(s, \"<\", \"&lt;\")\n\ts = strings.ReplaceAll(s, \">\", \"&gt;\")\n\ts = strings.ReplaceAll(s, \"\\\"\", \"&quot;\")\n\ts = strings.ReplaceAll(s, \"'\", \"&apos;\")\n\treturn s\n}\n","sourceCodeStart":402,"sourceCodeEnd":436,"githubUrl":"https://github.com/larksuite/cli/blob/7fd6ef3c07182257ce776cdc5a614e122d5bd4b3/shortcuts/slides/slides_create.go#L402-L436","documentation":"During slides creation, uploadSlidesPlaceholders uploads each '@path' placeholder file via uploadSlidesMedia. If an upload fails after the file was validated as a regular file, the error is re-wrapped as '@<path>: <cause>' preserving the typed cause with %w; the call site (appendSlidesProgressHint) reclassifies it. The wrapping only adds which placeholder file failed.","triggerScenarios":"Calling slides create/update with '@file' placeholders where uploadSlidesMedia fails for one of the files — e.g. unreadable file after stat, file too large for slides media, unsupported media type, or a network/API error during the media upload to the presentation.","commonSituations":"Files deleted or permissions changed between validation and upload; non-media or oversized assets; expired/insufficient auth token for media upload endpoints; transient network failures during large uploads.","solutions":["Read the wrapped cause after '@path:' — it identifies the underlying failure (auth, size, type, network) to fix.","Verify the file exists, is readable, and is a supported media type/size for Slides.","Re-run authentication (lark auth) if the cause indicates token/scope problems.","Retry on transient network errors; for large files check size limits before upload."],"exampleFix":"// before (file removed between check and upload)\nlark slides create --title t --content \"@/tmp/missing.png\"\n// after\nls -l /tmp/missing.png  # ensure present & readable, then re-run","handlingStrategy":"try-catch","validationCode":"info, err := os.Stat(path)\nif err != nil || !info.Mode().IsRegular() {\n\treturn fmt.Errorf(\"@%s: must be a regular file\", path)\n}\nif info.Size() > maxSlidesMediaBytes { return fmt.Errorf(\"@%s: file too large\", path) }","typeGuard":null,"tryCatchPattern":"token, err := upload(...)\nif err != nil {\n\tvar ve *errs.ValidationError\n\tif errors.As(err, &ve) { log.Printf(\"placeholder %s rejected: param=%s\", path, ve.Param) }\n\tif isRetryable(err) { return retryUpload(path) }\n\treturn fmt.Errorf(\"@%s: %w\", path, err)\n}","preventionTips":["Pre-flight check each @placeholder file exists, is a regular file, and meets size/type limits.","Refresh auth before large media uploads; handle token expiry.","Retry transient network failures with backoff."],"tags":["slides","file-upload","error-wrapping","cli"],"backgroundTag":"media-upload-failed","analyzedSha":"7fd6ef3c07182257ce776cdc5a614e122d5bd4b3","analyzedAt":"2026-09-04T21:17:44.649Z","contentChangedAt":"2026-09-04T21:17:44.649Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}