You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Generated multipart commands cannot upload binary fields other than the payload (e.g. pages deployments create _worker.js) #177
Generated multipart commands send --file to the payload field only. No other format: binary field in the multipart schema gets a flag, so those fields cannot be sent.
cf pages deployments create shows the problem. Its payload field resolves to _headers, so a Pages Direct Upload cannot include _worker.js, _routes.json, _redirects, _worker.bundle or functions-filepath-routing-config.json. cf pages deploy sends legacy Pages projects to npx wrangler pages deploy, so cf has no way to make an advanced-mode Pages deployment. One case that needs it is keeping a published *.pages.dev hostname while serving the content from a Worker. That needs a _worker.js that forwards to a service binding.
Reproduce (cf 1.0.0-beta.10)
cf pages deployments create my-project --manifest '{}' --branch main --help
# options: --body, --file, --branch, --commit-*, --manifest, --pages-build-output-dir, --wrangler-config-hash# there is no way to send _worker.js
--file ./_worker.js uploads the file under the _headers field instead.
Proposed fix (ready to merge)
PR creation in this repository is limited to collaborators, so I could not open a pull request. The fix is on this branch:
Commit: a single commit, fix: give every binary multipart field its own file flag, with a cf: patch changeset.
What it changes:
deriveArgsFromOp returns multipartFileFields: one path-valued flag for each binary field other than the payload. Leading _/. are dropped so the names parse as options: --worker-js, --routes-json, --redirects, --worker-bundle, --functions-filepath-routing-config-json. A name that would shadow --file, --body, a global flag, or another derived flag is skipped.
The flags are wired through the builder, the multipart handler (readFileForFlag + FormData.append with the file name), the dry-run preview (the flags appear in the body and set bodyKind to multipart), and _meta/commands.json.
pnpm generate changes two commands: pages deployments create and cloudforce-one requests assets upload, which gains --source.
Verification:
pnpm check passes.
New MSW test commands/multipart-file-fields.test.ts checks three things: each file reaches its own form field and _headers is not sent; the dry-run preview shows the file flags; an empty file is rejected before any request is made.
generator/arg-derivation.test.ts covers flag naming and the skipped collisions.
Live check against a real account: pages deployments create <p> --manifest '{}' --branch main --worker-js ./_worker.js deployed, and <p>.pages.dev served the uploaded worker's response.
Two unrelated test results from the full CLI suite on my machine: commands/auth/profiles.test.ts ("warns that login and logout target default in a bound directory") fails with a snapshot mismatch on unmodified main (45f8332) as well. The two lib/telemetry/dispatcher.test.ts agent tests fail only when an agent environment variable such as AI_AGENT is set.
Activity
fix: expose binary multipart fields as file flags