From e6f230fd7c610c297a26db9c77a06fa0aa7c1b6d Mon Sep 17 00:00:00 2001 From: Monica Renneke Date: Mon, 24 Aug 2026 10:26:58 -0400 Subject: [PATCH] Add placeholder API_KEY value with a guard check to both sample scripts Running either script without the user correctly setting the API_KEY variable fails with an authentication error. We added a check that displays a user-friendly message if the script detects the default placeholder value, "YOUR_API_KEY_HERE", instead of proceeding and failing with a confusing API error partway through. Matches the same change already applied to the embedded copies of these scripts in docs PR #1090 (commit 4ed81e1d). Co-Authored-By: Claude Sonnet 5 --- transform/sample-code/extract_quickstart.py | 4 +++- transform/sample-code/partition_quickstart.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/transform/sample-code/extract_quickstart.py b/transform/sample-code/extract_quickstart.py index 6d7506b..b070c7e 100644 --- a/transform/sample-code/extract_quickstart.py +++ b/transform/sample-code/extract_quickstart.py @@ -11,7 +11,9 @@ # This isn't best practice outside of local testing on your own machine. Once # you've added your real key, don't share this file or check it into any # repositories. -API_KEY = "" +API_KEY = "YOUR_API_KEY_HERE" +if API_KEY in ("YOUR_API_KEY_HERE", ""): + raise SystemExit("Set API_KEY to your Unstructured API key before running this script.") API_URL = "https://platform-api.transform.unstructured.io" # The local directory containing the file (or files) you want to process. INPUT_DIR = "/full/path/to/your/input/directory" diff --git a/transform/sample-code/partition_quickstart.py b/transform/sample-code/partition_quickstart.py index 29a2659..48dc873 100644 --- a/transform/sample-code/partition_quickstart.py +++ b/transform/sample-code/partition_quickstart.py @@ -11,7 +11,9 @@ # This isn't best practice outside of local testing on your own machine. Once # you've added your real key, don't share this file or check it into any # repositories. -API_KEY = "" +API_KEY = "YOUR_API_KEY_HERE" +if API_KEY in ("YOUR_API_KEY_HERE", ""): + raise SystemExit("Set API_KEY to your Unstructured API key before running this script.") API_URL = "https://platform-api.transform.unstructured.io" # The local directory containing the file (or files) you want to process. INPUT_DIR = "/full/path/to/your/input/directory"