Skip to content

docs: Add guide on validating Actor input with Pydantic#941

Open
vdusek wants to merge 9 commits into
masterfrom
docs/input-validation-guide
Open

docs: Add guide on validating Actor input with Pydantic#941
vdusek wants to merge 9 commits into
masterfrom
docs/input-validation-guide

Conversation

@vdusek

@vdusek vdusek commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Adds a guide on validating Actor input with Pydantic, so Actor code works with a typed, guaranteed-valid object instead of reaching into a raw input dictionary. Follows the structure of the existing guides.

  • docs/03_guides/11_pydantic.mdx — the guide: why raw-dict access is fragile, defining an input model (aliases bridging camelCasesnake_case, defaults, constraints, a custom validator, extra='ignore'), validating with model_validate and failing fast on ValidationError, the relationship to the platform input schema, and a few extra features (HttpUrl/EmailStr, model_validator, SecretStr).
  • code/11_pydantic.py — the runnable example Actor (Run on Apify), plus the 11_http_url.py, 11_model_validator.py, and 11_raw_input.py snippets.
  • Cross-links added to the Actor input concepts page and the quick-start guides list.

Verified locally for valid input (passes validation, writes OUTPUT, exit 0) and invalid input (per-field summary keyed by input-schema alias, run ends FAILED). Lint + type-check pass.

TODO before merging

  • Clone the guide content (docs/03_guides/11_pydantic.mdx + its docs/03_guides/code/11_*.py snippets) into website/versioned_docs/version-3.4/ so it also shows in the current docs version, not only under "next".

@vdusek vdusek added adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. labels Jun 5, 2026
@vdusek vdusek self-assigned this Jun 5, 2026
@github-actions github-actions Bot added this to the 142nd sprint - Tooling team milestone Jun 5, 2026
@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.70%. Comparing base (a87e8d1) to head (e8a0dea).
⚠️ Report is 1 commits behind head on master.

❗ There is a different number of reports uploaded between BASE (a87e8d1) and HEAD (e8a0dea). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (a87e8d1) HEAD (e8a0dea)
integration 1 0
Additional details and impacted files
@@             Coverage Diff             @@
##           master     #941       +/-   ##
===========================================
- Coverage   90.00%   78.70%   -11.31%     
===========================================
  Files          49       49               
  Lines        3053     3053               
===========================================
- Hits         2748     2403      -345     
- Misses        305      650      +345     
Flag Coverage Δ
e2e 35.66% <ø> (ø)
integration ?
unit 78.70% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vdusek vdusek changed the title docs: add guide on validating Actor input with Pydantic docs: Add guide on validating Actor input with Pydantic Jun 5, 2026
@vdusek vdusek requested a review from Mantisus June 5, 2026 18:56
@vdusek vdusek marked this pull request as ready for review June 5, 2026 18:57
@vdusek vdusek requested a review from szaganek as a code owner June 5, 2026 18:57

@Mantisus Mantisus left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM. Just a few suggestions

Comment thread docs/03_guides/code/11_pydantic.py Outdated
Comment thread docs/03_guides/11_pydantic.mdx Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants