-
Notifications
You must be signed in to change notification settings - Fork 72
Open
Description
Confirm this is a Typescript library issue and not an underlying Cloudflare API issue
- This is an issue with the Typescript library
Describe the bug
Currently there is no clear way how to upload scripts using SDK. I was trying to use workers.scripts.versions.create
methods, but there is clearly missing uploading actual scripts. When trying basic example:
async function deploy() {
const client = new Cloudflare({
apiToken: "****",
});
const version = await client.workers.scripts.versions.create("worker", {
account_id: "****",
metadata: {
main_module: "index.js",
},
});
console.log(version);
}
deploy().catch(console.error);
This always throws 400
with {"code":10021,"message":"could not read content for part metadata"}
. Looking on various support forum there is issue with compatibility_date
. Even setting this doesn't fix it I tried to add script content and metadata to body
, but same result. Could you please provide clearer guidance in example how to create a new version? We want to use this to create gradual deployment programatically.
To Reproduce
- Create script
async function deploy() {
const client = new Cloudflare({
apiToken: "****",
});
const version = await client.workers.scripts.versions.create("worker", {
account_id: "****",
metadata: {
main_module: "index.js",
},
});
console.log(version);
}
deploy().catch(console.error);
- Add correct
apiToken
andaccount_id
- Run it
node index.js
- There is error printed in terminal
Code snippets
OS
macOS Sequoia 15.5
Runtime version
Typescript 5.8.3
Library version
4.3.0
Metadata
Metadata
Assignees
Labels
No labels