Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

fix: Fix force permissions serialization for Actor calls#575

Merged
vdusek merged 1 commit into
masterapify/apify-client-python:masterfrom
fix-force-permission-level-serializationapify/apify-client-python:fix-force-permission-level-serializationCopy head branch name to clipboard
Jan 9, 2026
Merged

fix: Fix force permissions serialization for Actor calls#575
vdusek merged 1 commit into
masterapify/apify-client-python:masterfrom
fix-force-permission-level-serializationapify/apify-client-python:fix-force-permission-level-serializationCopy head branch name to clipboard

Conversation

@vdusek

@vdusek vdusek commented Jan 9, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@vdusek vdusek added this to the 131st sprint - Tooling team milestone Jan 9, 2026
@vdusek
vdusek requested a review from Pijukatel January 9, 2026 09:33
@vdusek vdusek self-assigned this Jan 9, 2026
@vdusek vdusek added bug Something isn't working. adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. labels Jan 9, 2026
@codecov

codecov Bot commented Jan 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 76.01%. Comparing base (f5d2941) to head (ebfd448).
⚠️ Report is 2 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #575   +/-   ##
=======================================
  Coverage   76.01%   76.01%           
=======================================
  Files          42       42           
  Lines        2468     2468           
=======================================
  Hits         1876     1876           
  Misses        592      592           
Flag Coverage Δ
integration 68.96% <ø> (ø)
unit 64.58% <ø> (ø)

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

☔ View full report in Codecov by Sentry.
📢 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 merged commit 4a763f6 into master Jan 9, 2026
30 checks passed
@vdusek
vdusek deleted the fix-force-permission-level-serialization branch January 9, 2026 09:42
vdusek added a commit that referenced this pull request May 3, 2026
## Issue

- Closes #576

## Description

Replaces every generated `class X(StrEnum)` with a `X = Literal[...]`
alias. Users pass plain strings (`status='RUNNING'`) instead of enum
members, the aliases are reusable across method signatures, and behavior
matches Crawlee and the Apify SDK — avoiding mixing-enum-with-string
footguns like #575.

## Why post-processing

The natural fix — `--enum-field-as-literal=all` + `--use-type-alias` on
`datamodel-code-generator` — only handles enums referenced from
operation parameters; the rest get inlined at every reference site with
no stable name to import. Filed upstream as
[koxudaxi/datamodel-code-generator#3104](koxudaxi/datamodel-code-generator#3104).
Until that lands, `scripts/postprocess_generated_models.py` does the
rewrite ourselves; once fixed, we can drop the post-processing.

## What the post-process does

- **`convert_enums_to_literals`** — rewrites every top-level `class
X(StrEnum)` to `X = Literal[...]`, preserving value order and class
docstring.
- **`deduplicate_error_type_enum`** — removes the duplicate inlined
`class Type(StrEnum)` datamodel-codegen emits alongside the named
`ErrorType` (same upstream issue), and rewires `Type` annotations to
`ErrorType`. AST-based.
- **`split_literals_to_file`** — moves the 11 alias blocks into
`_literals_generated.py` so consumers don't pull in every Pydantic
model.
- **`snake_case_camelcase_literal_values`** — converts camelCase string
values (`StorageOwnership`'s `'ownedByMe'`/`'sharedWithMe'`) to
snake_case and emits `_<NAME>_WIRE_VALUES` so resource clients can
convert back to the wire format.

The hand-maintained `_types.py` is renamed to `_literals.py` for
symmetry.

## Consumers

- All internal code imports the aliases via `TYPE_CHECKING` where
possible.
- `dataset_collection`, `key_value_store_collection`,
`request_queue_collection` translate `ownership` back to wire format via
`_STORAGE_OWNERSHIP_WIRE_VALUES`.
- `_TERMINAL_STATUSES` in `_resource_client.py` is derived from
`TerminalActorJobStatus` via `typing.get_args()` — single source of
truth.
- Docstrings, integration tests, unit tests, and the two
`docs/02_concepts/code/03_nested_*.py` examples no longer reference
`.MEMBER` / `.MEMBER.value`.

## Tests

`tests/unit/test_postprocess_generated_models.py` covers each step
independently plus a full-pipeline integration test.

## Breaking change

Tracked under v3 on #576. `ActorJobStatus.RUNNING` and similar
enum-member access no longer exists — pass the plain string instead.
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. bug Something isn't working. 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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.