cloudflare / cloudflare/cloudflare-go
Multipart encoding regression in v7.8.0 and later
- 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
A bug reported a year ago in https://github.com/cloudflare/cloudflare-go/issues/4174 was fixed in https://github.com/cloudflare/cloudflare-go/pull/4187 and then broken on the 7.8.0 release when the code was regenerated and all the fixes nuked out.
### To Reproduce
```go
package main
import (
"fmt"
"github.com/cloudflare/cloudflare-go/v7"
"github.com/cloudflare/cloudflare-go/v7/workers"
)
func main() {
p := workers.ScriptScriptAndVersionSettingEditParams{
AccountID: cloudflare.F("acct-id"),
Settings: cloudflare.F(workers.ScriptScriptAndVersionSettingEditParamsSettings{
CompatibilityDate: cloudflare.F("2026-01-01"),
Bindings: cloudflare.F([]workers.ScriptScriptAndVersionSettingEditParamsSettingsBindingUnion{
workers.ScriptScriptAndVersionSettingEditParamsSettingsBindingsWorkersBindingKindPlainText{
Name: cloudflare.F("ATTESTATION_CERT"),
Text: cloudflare.F("pem-blob-here"),
Type: cloudflare.F(workers.ScriptScriptAndVersionSettingEditParamsSettingsBindingsWorkersBindingKindPlainTextTypePlainText),
},
}),
}),
}
data, ct, err := p.MarshalMultipart()
if err != nil {
fmt.Println("ERROR:", err)
return
}
fmt.Println("content-type:", ct)
fmt.Println(string(data))
}
```
Works on `v7.7.0`:
```
% go get github.com/cloudflare/cloudflare-go/v7@v7.7.0 && go run .
content-type: multipart/form-data; boundary=86b0ba6783304b0860804babc4e3b9f8a3a37a9ab8a311ec495a40780f2c
--86b0ba6783304b0860804babc4e3b9f8a3a37a9ab8a311ec495a40780f2c
Content-Disposition: form-data; name="settings"
Content-Type: application/json
{"bindings":[{"name":"ATTESTATION_CERT","text":"pem-blob-here","type":"plain_text"}],"compatibility_date":"2026-01-01"}
--86b0ba6783304b0860804babc4e3b9f8a3a37a9ab8a311ec495a40780f2c--
```
Borked on `v7.9.0`:
```
% go get github.com/cloudflare/cloudflare-go/v7@v7.9.0 && go run .
content-type: multipart/form-data; boundary=c88870f0ce022a97ede987ac5de006852cfdc54844712a95a8a28672a342
--c88870f0ce022a97ede987ac5de006852cfdc54844712a95a8a28672a342
Content-Disposition: form-data; name="settings.bindings.0.name"
ATTESTATION_CERT
--c88870f0ce022a97ede987ac5de006852cfdc54844712a95a8a28672a342
Content-Disposition: form-data; name="settings.bindings.0.text"
pem-blob-here
--c88870f0ce022a97ede987ac5de006852cfdc54844712a95a8a28672a342
Content-Disposition: form-data; name="settings.bindings.0.type"
plain_text
--c88870f0ce022a97ede987ac5de006852cfdc54844712a95a8a28672a342
Content-Disposition: form-data; name="settings.compatibility_date"
2026-01-01
--c88870f0ce022a97ede987ac5de006852cfdc54844712a95a8a28672a342--
```
### Code snippets
```Go
```
### OS
macOS
### Go version
go version go1.27.0 darwin/arm64
### Library version
github.com/cloudflare/cloudflare-go/v7@v7.9.0
Contributor guide
Research direction
Start with workers.ScriptScriptAndVersionSettingEditParams.MarshalMultipart and run the provided reproduction against v7.7.0 and v7.9.0. Review the fix in issue #4174 and pull request #4187, along with the regeneration changes. Done means nested settings are emitted as the JSON multipart part shown for v7.7.0, with the existing binding data preserved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100