Skip to content

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

Draft
vdusek wants to merge 2 commits into
masterfrom
docs/input-validation-guide
Draft

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

Conversation

@vdusek
Copy link
Copy Markdown
Contributor

@vdusek vdusek commented Jun 5, 2026

Adds a new 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 scraping-library guides.

What's included

  • docs/03_guides/10_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 Pydantic features (HttpUrl/EmailStr, model_validator, SecretStr).
  • docs/03_guides/code/10_pydantic.py — the runnable example Actor, shown via RunnableCodeBlock (Run on Apify) like the other guides. It validates the input, logs the normalized values, and stores them as OUTPUT.
  • Cross-link to the new guide added to the Actor input concepts page and to the quick-start Guides list.

Verification

  • The example Actor was run locally for both valid and invalid input: valid input passes validation and writes OUTPUT (exit 0); invalid input logs a per-field summary (errors referenced by their input-schema aliases) and the run ends FAILED.
  • ruff check, ruff format --check, and ty check pass.

Numbered 10 to sit after the in-progress uv (#932, 08) and Scrapling (#938, 09) guides.

@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
Copy link
Copy Markdown

codecov Bot commented Jun 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.87%. Comparing base (3f25d4a) to head (a27cf5a).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #941   +/-   ##
=======================================
  Coverage   86.87%   86.87%           
=======================================
  Files          48       48           
  Lines        2942     2942           
=======================================
  Hits         2556     2556           
  Misses        386      386           
Flag Coverage Δ
e2e 37.76% <ø> (ø)
integration 59.10% <ø> (ø)
unit 75.62% <ø> (ø)

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.

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.

2 participants