Skip to content

KV binding defaults to STORAGE when driver explicitly set #766

@onmax

Description

@onmax

when working on #765, i found that when explicitly setting driver: 'cloudflare-kv-binding' in hub.kv config, the binding property is not set to default 'KV', causing unstorage to use 'STORAGE'.

Reproduce

// nuxt.config.ts
export default defineNuxtConfig({
  hub: {
    kv: {
      driver: 'cloudflare-kv-binding',
      namespaceId: '<id>'
    }
  }
})

Deploy to Cloudflare Workers → 500 error: [unstorage] [cloudflare] Invalid binding 'STORAGE': undefined

Cause

resolveKVConfig() in src/kv/setup.ts returns early when driver is explicitly set (line 16), skipping the Cloudflare defaults merge at lines 48-51 that adds binding: 'KV'.

Workaround

Add binding: 'KV' explicitly.

Expected

binding: 'KV' should be merged even when driver is explicitly specified.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions