Skip to content

docs(worker): state the job-variable trust model and the absence of limits - #434

Merged
emilyoram merged 4 commits into
mainfrom
docs/426-job-variable-trust-model
Nov 20, 2026
Merged

emilyoram merged 4 commits into
mainfrom
docs/426-job-variable-trust-model

Conversation

@claude

@claude claude Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Joshua Wulf · Slack thread

Before: The policy asks each SDK to decide and document two things about job variables — whether it enforces size and depth limits, and the trust model for handler authors. Neither was stated anywhere a handler author would look. The README documents the trust model of the process execution strategy, and does it well, but that is a different question. Nothing said that job.variables and job.custom_headers are untrusted input, or what the SDK does and does not do about them.

After: Both are written down, for end users in the README and in the JobContext attribute docs so they reach IDE hovers.

A handler author can now see, where they are already looking, that variable content comes from whoever started the process instance and what the SDK does not check.

How: This documents the current position rather than changing it. What the SDK does: deserialisation is JSON-only, into plain containers, never instantiating a class from the payload; each job gets its own context, so variables are not shared or mutated across concurrent jobs. What it does not do: no size limit, no depth limit beyond CPython's own recursion limit during parsing, and no validation of content against a schema. Each "does not" is paired with what to use instead — WorkerConfig.fetch_variables to bound what a worker receives, the handler's own bound on recursion, search_variables_as_dto to validate.

No limit is invented. The issue asks for a documented decision, and the decision recorded here is the one the code already makes. Picking a maximum payload size or nesting depth would be a behaviour change that could break a working deployment, and it needs a product decision and a cross-SDK number, not a guess in a docs PR. If you want limits enforced, that is a separate issue and I am happy to open it.

No code behaviour changes: a docstring and a README section.

Deliberately kept clear of PR #420. That PR documents the process strategy's pickle boundary and inserts into the README's execution-strategies section (around line 583) and into the JobContext class docstring's opening prose. This one adds a new ### Job Variables Are Untrusted Input section about 110 lines earlier, before "Using the Client in a Job Handler", and adds variables / custom_headers entries to the docstring's existing Attributes: block. I ran a trial merge of this branch with #420's branch: it auto-merges cleanly, in README.md, runtime/job_worker.py and the regenerated copy. The two can land in either order, and the README section here links to the execution-strategies section rather than restating it.

Verification on Python 3.13 (make generate-only, then the Makefile validation steps): ruff check ., ty check, ty check examples/, the README snippet check and the config-reference generator are clean; pytest tests/acceptance is 842 passed, 1 skipped — unchanged, as expected for a docs change. The README section contains no fenced code block, so it does not interact with the snippet-injection rule.

Commits follow the repo's split rule: the runtime/ and README change, then the regenerated copy, then the same pair again for Copilot's two factual corrections — custom headers come from the BPMN model rather than from whoever starts an instance, and search_variables_as_dto searches rather than validating what a job handed you, so the docs now point at MyModel.model_validate(job.variables.to_dict()).

Closes #426

🤖 Generated with Claude Code

https://claude.ai/code/session_01RcVhnekJQeXnMfPhs9pYda

…imits

The policy asks each SDK to decide and document two things about job variables.
Neither was stated anywhere a handler author would look. The README documents
the trust model of the process execution strategy, but that is a different
question, and nothing said that variables and custom headers are untrusted input
or what the SDK does and does not do about them.

Documents the current position rather than changing it: deserialisation is
JSON-only and never instantiates a class from the payload, each job gets its own
context, and there is no size limit, no depth limit and no content validation.
Says what to use instead -- fetch_variables to bound what a worker receives,
your own bound on recursion, search_variables_as_dto to validate. No limit is
invented here: choosing one would be a design decision with a behaviour change
behind it, and it is not this issue's to make.

A new README subsection for end users, mirrored in the JobContext attribute
docs so it reaches IDE hovers.

Closes #426

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RcVhnekJQeXnMfPhs9pYda
@claude
claude Bot requested a balanced review from Copilot November 13, 2026 06:49
@claude
claude Bot marked this pull request as ready for review November 13, 2026 06:51
@claude
claude Bot requested a review from a team as a code owner November 13, 2026 06:51

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The documentation misstates input validation and trust boundaries by presenting an unvalidated variable search as validation of job inputs and attributing model-defined custom headers to instance callers or message payloads.

2 open issues
What changed in this PR

Documents the job-variable trust model for SDK handler authors, addressing #426 without changing runtime behavior. This complements the separate process-pool trust documentation in #420.

Changes:

  • Adds README guidance on untrusted inputs, JSON deserialization, per-job isolation, and the absence of SDK-enforced size, depth, and schema checks.
  • Mirrors the guidance in JobContext attribute documentation for IDE hovers and refreshes the generated copy.
File Description
runtime/​job_worker.py Adds trust and validation guidance to JobContext attribute docs.
README.md Adds the “Job Variables Are Untrusted Input” section.
generated/​camunda_orchestration_sdk/​runtime/​job_worker.py Mirrors the source docstring in the generated SDK.

Review effort: Balanced

Comment thread README.md Resolved
Comment thread README.md Resolved
From Copilot's review, two factual corrections to the new section.

Custom headers are defined in the BPMN model at modelling time, not supplied by
whoever starts an instance, so lumping them in with variables misstated the trust
boundary. They are now given their own origin, and the trust that follows from it:
as far as control over who may deploy a process definition goes.

search_variables_as_dto does not validate the variables a job handed you. It runs
a separate search, derives its query from a model's fields, and returns a
VariableMap whose values stay unvalidated until .validate() is called. The
handler's own input is validated with MyModel.model_validate(
job.variables.to_dict()), which is what the docs now say.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RcVhnekJQeXnMfPhs9pYda

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

There are no active review issues blocking this documentation-only clarification of the job-variable trust model.

No open issues 🎉

Review effort: Balanced

@emilyoram
emilyoram merged commit e02316c into main Nov 20, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs(worker): document the job-variable trust model and the absence of size and depth limits

3 participants