cloudflare / cloudflare/cloudflare-go
Workers for Platforms: Subdirectory paths in multipart file uploads cause error 10021
- Dominant language
- Go
- Stars
- 2.1k
- Forks
- 781
- Avg merge
- 12h 38m
- Merged PRs (30d)
- 4
Description
### Confirm this is a Go library issue and not an underlying Cloudflare API issue
- [x] This is an issue with the Go library
### Describe the bug
When uploading worker scripts via the Workers for Platforms dispatch namespace API, files with subdirectory paths (e.g., worker/index.js) fail with error 10021, while flat file names (e.g., worker-index.js) succeed.
Note: I do not know if this is _only_ an issue on workers for platforms or applies to all workers. I also do not know if this is an issue specific to the Go library or if this is an underlying API issue. Please report it to the API team if it's an underlying issue.
### To Reproduce
1. Upload a worker with MainModule: "worker/index.js" and files named worker/index.js, worker/api.js
2. Request fails with error 10021
3. Rename files to worker-index.js, worker-api.js and set MainModule: "worker-index.js"
4. Request succeeds
### Code snippets
```Go
// FAILS - subdirectory paths
client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Update(ctx, "namespace", "worker-name",
workers_for_platforms.DispatchNamespaceScriptUpdateParams{
AccountID: cloudflare.F(accountID),
Metadata: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptUpdateParamsMetadata{
MainModule: cloudflare.F("worker/index.js"),
}),
Files: cloudflare.F([]io.Reader{
&NamedReader{Reader: strings.NewReader(script), Filename: "worker/index.js"},
}),
})
// WORKS - flat paths
client.WorkersForPlatforms.Dispatch.Namespaces.Scripts.Update(ctx, "namespace", "worker-name",
workers_for_platforms.DispatchNamespaceScriptUpdateParams{
AccountID: cloudflare.F(accountID),
Metadata: cloudflare.F(workers_for_platforms.DispatchNamespaceScriptUpdateParamsMetadata{
MainModule: cloudflare.F("worker-index.js"),
}),
Files: cloudflare.F([]io.Reader{
&NamedReader{Reader: strings.NewReader(script), Filename: "worker-index.js"},
}),
})
```
### OS
macOS
### Go version
Go 1.25.6
### Library version
github.com/cloudflare/cloudflare-go/v6 v6.4.0
Contributor guide
Assessment
This issue has not been assessed yet.