Skip to content

feat: blacklist-based Worker config types + adopt existing remote resources#2

Merged
jonasnobile merged 6 commits into
mainfrom
feat/config-types
Jun 17, 2026
Merged

feat: blacklist-based Worker config types + adopt existing remote resources#2
jonasnobile merged 6 commits into
mainfrom
feat/config-types

Conversation

@jonasnobile

@jonasnobile jonasnobile commented May 5, 2026

Copy link
Copy Markdown
Member

Summary

This branch bundles a config-type refactor with a resource-adoption fix and supporting tests.

Worker config types (blacklist)

  • Replace the Pick<Config, …> whitelist of allowed Worker config fields with an Omit<Config, …> blacklist of oblaka-managed fields.
  • New wrangler binding types (hyperdrive, pipelines, mtls_certificates, ratelimits, tail_consumers, dispatch_namespaces, secrets_store_secrets, unsafe, …) now fall through as raw config until a dedicated oblaka resource is added.
  • The blacklist covers only identity fields (name, compatibility_flags, account_id), resource-managed bindings (kv_namespaces, r2_buckets, d1_databases, queues, durable_objects, migrations, workflows, containers, send_email, services, vectorize, analytics_engine_datasets, browser, images, version_metadata, worker_loaders, vpc_networks, ai_search_namespaces, flagship) and hidden cache.

Adopt existing remote resources instead of failing on create

  • On lost state, a blind create either fails with a conflict (Worker, R2, Queues) or silently spawns a duplicate (D1 allows same-name databases — risking data loss). Each resource now looks itself up by name first and adopts the existing one.
  • List calls request per_page=1000 (matching the KV namespace lookup in state.ts) so an existing resource past the default first page is still found; D1 filters server-side by name.

Tests

  • Add a shared mock-client test helper.
  • Cover the adopt-existing and create-when-absent paths for Worker, D1, R2, and Queues.
  • Add a @ts-expect-error assertion proving the Worker blacklist rejects oblaka-managed fields (e.g. kv_namespaces) while still accepting raw passthrough fields.

Release

  • Bump version to 0.0.15.

Known limitations

  • per_page=1000 raises the adoption ceiling to 1000 resources per type per account rather than doing unbounded cursor pagination (consistent with existing code).
  • The list→create adoption path is not atomic (TOCTOU); concurrent deploys of the same env could still race.

Test plan

  • bun run typecheck
  • bun run format:check
  • bun run lint
  • bun test (87 pass)

🤖 Generated with Claude Code

Switch from a Pick whitelist to an Omit blacklist so that new wrangler
config options (and binding types without an oblaka resource yet) fall
through automatically as a fallback. The blacklist excludes only fields
managed by oblaka resources, identity fields handled at the top level,
and hidden internal fields.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@jonasnobile jonasnobile force-pushed the feat/config-types branch from fc5fbc5 to 9f9eea6 Compare May 5, 2026 08:55
@jonasnobile jonasnobile changed the title feat: allow placement, tsconfig, preserve_file_names, secrets on Worker resource refactor: invert Worker config filter to blacklist oblaka-managed fields May 5, 2026
jonasnobile and others added 5 commits June 17, 2026 22:35
… level

Add @ts-expect-error coverage proving kv_namespaces is rejected by the
Omit blacklist (and that non-managed raw config fields still pass through),
locking in the contract introduced by the whitelist-to-blacklist refactor.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Cover remote-state adoption and create paths using the shared
mock-client helper, mirroring the Worker resource tests.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
On lost state, a blind create either fails with a conflict (Worker, R2,
Queues) or silently spawns a duplicate (D1 allows same-name databases,
risking data loss). Look each resource up by name first and adopt it.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
The Worker, Queues, and R2 list endpoints were fetched with the default
page size, so an existing resource past page one would be missed and the
adopt-on-create path would fall through to a conflicting blind create.
Request per_page=1000 (matching the KV namespace lookup in state.ts) so
adoption sees the full set. D1 already filters server-side by name.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
@jonasnobile jonasnobile changed the title refactor: invert Worker config filter to blacklist oblaka-managed fields feat: blacklist-based Worker config types + adopt existing remote resources Jun 17, 2026
@jonasnobile jonasnobile merged commit e32a4c2 into main Jun 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant