Skip to content

SDK panics when deserializing Worker settings with empty Placement object #4232

@arafato

Description

@arafato

Confirm this is a Go library issue and not an underlying Cloudflare API issue

  • This is an issue with the Go library

Describe the bug

When calling Workers.Scripts.ScriptAndVersionSettings.Get(), the SDK panics if the API returns an empty placement object ("placement": {}).

Panic:
reflect: call of reflect.Value.SetString on struct Value

Reproduction:

settings, err := client.Workers.Scripts.ScriptAndVersionSettings.Get(ctx, "my-worker",
    workers.ScriptScriptAndVersionSettingGetParams{
        AccountID: cloudflare.F("..."),
    })
// panics before returning — err is never set
The API response contains:
{
  result: {
    placement: {},
    bindings: [ ... ],
    ...
  }
}

The panic occurs in the union deserializer for the Placement field (ScriptScriptAndVersionSettingGetResponsePlacement). When the API returns an empty object {} for placement, the reflection-based union deserialization attempts to call SetString on a struct value, which is invalid.
Impact: The entire settings response is lost, including unrelated fields like bindings, compatibility_date, compatibility_flags, and tail_consumers. There is no way to catch this via the returned error — the panic must be caught with recover(), but at that point the response pointer is nil.

SDK version: cloudflare-go/v6 v6.6.0

To Reproduce

settings, err := client.Workers.Scripts.ScriptAndVersionSettings.Get(ctx, "my-worker",
    workers.ScriptScriptAndVersionSettingGetParams{
        AccountID: cloudflare.F("..."),
    })
// panics before returning — err is never set
The API response contains:
{
  result: {
    placement: {},
    bindings: [ ... ],
    ...
  }
}

### Code snippets

```Go

OS

macOs

Go version

go version go1.25.1 darwin/arm64

Library version

SDK version: cloudflare-go/v6 v6.6.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions