cloudflare-go
cloudflare-go copied to clipboard
KV stores value as a json
Confirm this is not a feature request
- [x] This is a bug
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
Using client.KV.Namespaces.Values.Update stores KV value as {"value": "...."}.
type NamespaceValueUpdateParams struct {
// Identifier
AccountID param.Field[string] `path:"account_id,required"`
// Arbitrary JSON to be associated with a key/value pair.
Metadata param.Field[string] `json:"metadata,required"`
// A byte sequence to be stored, up to 25 MiB in length.
Value param.Field[string] `json:"value,required"`
// The time, measured in number of seconds since the UNIX epoch, at which the key
// should expire.
Expiration param.Field[float64] `query:"expiration"`
// The number of seconds for which the key should be visible before it expires. At
// least 60.
ExpirationTTL param.Field[float64] `query:"expiration_ttl"`
}
To Reproduce
_, err = client.KV.Namespaces.Values.Update(
context.Background(),
{namespaceid},
{keyid},
kv.NamespaceValueUpdateParams{
AccountID: cloudflare.F({account_id}),
Value: cloudflare.F({value}),
Expiration: cloudflare.F(float64({expiry})),
},
)
Code snippets
OS
Windows
Go version
Go 1.23
Library version
github.com/cloudflare/cloudflare-go/[email protected]