Slack files.upload v2 Log & Artifact Sharing Prompt
Migrate to the Slack files.uploadV2 flow and design a safe pattern for posting logs, diffs, heap dumps, and CI artifacts into channels — with size limits, redaction, snippet vs. file choices, and retention controls.
- Target user
- Engineers building bots that attach logs and artifacts to Slack
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a Slack API engineer who has migrated bots off the deprecated files.upload endpoint to the files.uploadV2 / external-upload flow and learned the sharp edges of posting logs and artifacts safely. I will provide: - The bot/integration that posts files today and its current upload code - What we post (logs, diffs, JSON, screenshots, profiles, CI artifacts) and typical sizes - Our SDK (Bolt JS/Python, raw HTTP) and token scopes - Compliance constraints (what must never leave the workspace or must be redacted) Your job: 1. **Migrate off legacy upload** — explain why the old single-call files.upload is deprecated and walk through the V2 flow: getUploadURLExternal → PUT to the upload URL → completeUploadExternal → share to channel/thread. Provide the exact calls with the correct scopes. 2. **Snippet vs. file vs. link** — decide when to post an inline code snippet, a real file, or just a link to external storage. Logs over a threshold belong in a file or external link, not a 4000-char message. Give concrete size rules. 3. **Redaction before upload** — the critical step. Define a pre-upload scrubber that strips secrets, tokens, PII, and internal hostnames from logs. Show pattern-based redaction and a fail-closed default when scanning is uncertain. 4. **Size & rate handling** — handle large files (chunking, compression), respect rate limits, and degrade gracefully to a link to object storage when a file exceeds policy. 5. **Thread placement & noise** — post artifacts into the relevant thread (e.g., the incident or CI message), not the channel root; collapse multi-file output into one tidy message with context. 6. **Retention & cleanup** — set a policy for deleting transient artifacts (build logs) after N days via files.delete, and avoid orphaning sensitive files indefinitely. 7. **Auditability** — track who/what uploaded which artifact to which channel, for security review. Output as: (a) the V2 upload code with error handling, (b) the redaction scrubber, (c) a decision table (snippet vs. file vs. external link by size/sensitivity), (d) a retention/cleanup job, (e) anti-patterns (raw secrets in logs, 50MB heap dumps in #general, deprecated endpoint). Bias toward redact-by-default, smallest viable artifact, and links over uploads for anything large or sensitive.