docs(python): document environment= kwarg on arcjet() / arcjet_sync()#829
docs(python): document environment= kwarg on arcjet() / arcjet_sync()#829estellajaysong wants to merge 4 commits into
environment= kwarg on arcjet() / arcjet_sync()#829Conversation
…ync()` Covers the pydantic-settings escape hatch added in arcjet/arcjet-py#127: pass `environment=settings.ARCJET_ENV` so dev-mode gating (loopback IP fallback, `X-Arcjet-Ip` override, dev-mode timeout) works when the config library doesn't propagate `.env` into `os.environ`. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…ctive audit - Lead the pydantic-settings subsection with the directive (use the kwarg) and explain the library design difference rather than framing it as silent SDK failure. - State accepted values (`"development"` / `"production"`) inline on the optional-fields bullet so readers don't have to dig into the subsection to learn what strings the kwarg accepts. - Trim the trailing migration note; keep the `arcjet_sync()` mention. - Mirror the tone change in `environment.mdx`. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Drop the dev-mode behavior enumeration from the pydantic-settings subsection; the cross-link to `environment.mdx#arcjet-env` carries that detail. - Compact the pointer paragraph in `environment.mdx` to a single line so the page stays a concept reference rather than absorbing Python-SDK-specific mechanism notes. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
There was a problem hiding this comment.
Arcjet Review — 🟢 Low Risk
Decision: Approved
Rationale: Documentation-only change that adds guidance for Python SDK users on the existing environment= kwarg, particularly when using pydantic-settings which doesn't propagate .env into os.environ. No code changes, no security implications, no escalation triggers fired. Example code is a typical pydantic-settings pattern with no hardcoded secrets (key is sourced from settings).
Summary of Changes
Adds documentation in environment.mdx and reference/python.mdx explaining that Python SDK users on pydantic-settings (or similar config libraries that don't write back to os.environ) should pass ARCJET_ENV via the environment= kwarg on arcjet() / arcjet_sync(). Includes a new 'Pydantic-settings users' subsection with a code example and cross-links between the two docs pages.
Notes
Docs-only PR, well under the 1000-line threshold. Security-review skill checklist applied: no secrets, no auth/crypto/injection surface touched; example code uses settings-sourced key rather than a hardcoded value.
Review: 983e0c7c | Powered by Arcjet Review
…s example The example is illustrating the exact case where customers hit the issue — local dev. Defaulting to "development" matches that intent and makes the wiring testable without setting the value in `.env`. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
To be merged post Python SDK release for the relevant feature: arcjet/arcjet-py#127 |
Summary
Documents the
environment=kwarg shipped in arcjet/arcjet-py#127. Users onpydantic-settings(or any config library that doesn't propagate.envintoos.environ) can now pass dev/prod mode explicitly instead of relying onARCJET_ENVbeing readable viaos.getenv.src/content/docs/reference/python.mdx— Addsenvironmentto the Configuration optional-fields bullet list with"development"/"production"stated inline, plus a new#### Pydantic-settings userssubsection with a runnableBaseSettingsexample.arcjet_sync()is called out for Flask/Django users.src/content/docs/environment.mdx— Adds a one-line pointer under### ARCJET_ENV, NODE_ENVso customers who land on the concept page searchingARCJET_ENVget routed to the kwarg. Mechanism explanation lives on the reference page only.Why
pydantic-settings— the de-facto FastAPI config pattern — loads.envinto a typedBaseSettingsobject by design and does not write values back toos.environ. The Python SDK readsARCJET_ENVviaos.getenv, so without an explicit channel between the two, the SDK defaults to production mode for users on this pattern. The newenvironment=kwarg is that bridge, and the docs need to point users to it where they'll look for the symptom.Test plan
Open the Vercel preview link from the PR's checks (sidebar → "Visit Preview"), then walk through:
/reference/pythonon the preview. Scroll down to (orCmd+F) thePydantic-settings usersheading. Click the heading and confirm the URL becomes…/reference/python#pydantic-settings-users.environmentbullet (betweenproxiesand the FastAPI/Flask code tabs). Click the Pydantic-settings users link in that bullet. Confirm it jumps to the subsection on the same page.environmentbullet, click theARCJET_ENVlink. Confirm it navigates to/environment#arcjet-envand scrolls to theARCJET_ENV, NODE_ENVheading./environmentdirectly on the preview. Find theARCJET_ENV, NODE_ENVsection. Click the Python SDK reference link in the "Python SDK users: …" sentence. Confirm it lands on/reference/python#pydantic-settings-users./reference/python, read the Configuration section end-to-end (from### Configurationthrough#### Load balancers & proxies) and confirm the new bullet and subsection sit naturally in the flow with no rendering glitches.🤖 Generated with Claude Code