Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
apify pushreads.actor/actor.jsonwith a plainJSON.parseand checks none of its file-path fields. The platform resolvesdockerfile,readme,changelog, and every string-valued schema reference relative to.actor/after the upload: a missing schema file fails the build, and a missingdockerfile,readme, orchangelogonly logs a warning on the worker side and falls back to the default, so the build goes green with the wrong image or README.This PR adds a pre-flight check that applies the worker's path rules in the CLI, after the config is read and before the Actor is looked up or written. It needs no platform change.
Closes #1500. Part of apify/apify-core#28685.
Stacked on the preflight PR (#1502, branch
feat/push-monorepo-preflight): the check runs right after thedockerContextDirresolver, so a monorepo Actor still gets the stage 1 refusal first.Changes
src/lib/actor-paths.ts:checkActorPaths({ actorDir, uploadRoot, uploadedFiles, config, dockerContextRoot? })returns one problem (field, value, resolved path, reason) per failing field, andformatActorPathProblemsturns the list into the error message.dockerfile,readme,changelog,input,output,webServerSchema,storages.keyValueStore,storages.dataset, andstorages.datasets.*. Object values (inline schemas) are skipped, anddockerContextDirstays with the resolver..actor/, not absolute, inside the upload root (lexically and after symlink resolution), an existing file rather than a directory, and among the files push uploads (which catches a Dockerfile excluded by.gitignoreor.actorignore). The name matches case-insensitively fordockerfile,readme, andchangelog, as the worker finds those by a directory listing, and exactly otherwise.src/commands/actors/push.ts: calls the check with the Actor folder as the upload root and the file list push already collected. A failure prints every problem and exits withCommandExitCodes.InvalidActorJson(5).src/lib/docker-context.ts: exports the existingisOutsideandtoPosixhelpers for reuse.apify pushwork for monorepo Actors that setdockerContextDir#595, stage 2) can pass the Git repository root asuploadRootand the context asdockerContextRoot; the check then also requiresdockerfileinside the Docker context.Tests
test/local/lib/actor-paths.test.ts(unit):./xand../xinside the root pass; a path above the root, an absolute path, a missing file, a directory, a file excluded by.actorignore, and a symlink to a file outside the root fail; a wrong-casedockerfileandreadmepass and a wrong-caseinputfails; every string-valued schema reference is checked; inline schema objects and a config without path fields are no-ops;dockerfileoutside an explicitdockerContextRootfails.test/local/commands/push-actor-paths.test.ts(mocked client): wrongdockerfile,readme, andinputstop push with exit code 5, every problem listed, and no Actor read or write; stdout stays clean with--json; valid paths push as usual.pnpm run lint,pnpm run format,pnpm run build, andpnpm run test:local: 765 passed, 2 failed. The two failures are the[python]template tests (python_support.test.tsandworks-with-spaces-in-path-to-actor.test.ts), which cannot create a.venvwith the Python 3.9 on this machine; they do not touch push.pnpm run update-docsproduced no change: no flag, argument, or description changed.test:api(needs a platform token). No e2e test was added, because the login check precedes the config read, so a token-free e2e run exits with code 1 first.enginesasks for 22 or newer). The review pass repeated lint, format, build,update-docs, andtest:localon Node.js 24.18.0 through nvm with the same result.Notes for reviewers
statSync, so a wrong-caseinputfails on macOS and Windows as it would on the Linux worker.dockerContextDirabove the upload root keeps exit code 255 and the stage 1 message, since the resolver runs first.dockerfile,readme, orchangelogpasses here because the worker accepts it; a reviewer may prefer a warning for it, which this PR does not add.🤖 Generated with Claude Code