Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 BUG: --from-dash doesn't know about the shape of all bindings #6735

Closed
KianNH opened this issue Sep 17, 2024 · 0 comments · Fixed by #6791
Closed

🐛 BUG: --from-dash doesn't know about the shape of all bindings #6735

KianNH opened this issue Sep 17, 2024 · 0 comments · Fixed by #6791
Labels
bug Something that isn't working

Comments

@KianNH
Copy link
Contributor

KianNH commented Sep 17, 2024

Which Cloudflare product(s) does this pertain to?

C3 (npm create cloudflare), Wrangler

What version(s) of the tool(s) are you using?

3.78.3 [Wrangler], 2.27.0 [C3]

What version of Node are you using?

22.6.0

What operating system and version are you using?

macOS 14.6.1

Describe the Bug

When using --existing-script in C3 or --from-dash in Wrangler, Queue bindings are shown in Wrangler.toml as their unsafe shape.

[unsafe]
  [[unsafe.bindings]]
  name = "QUEUE"
  queue_name = "docs-v2-test"
  type = "queue"

It looks like Queues is missing from the below switch statement:

switch (binding.type) {
case "plain_text":
{
configObj.vars = {
...(configObj.vars ?? {}),
[binding.name]: binding.text,
};
}
break;
case "json":
{
configObj.vars = {
...(configObj.vars ?? {}),
name: binding.name,
json: binding.json,
};
}
break;
case "kv_namespace":
{
configObj.kv_namespaces = [
...(configObj.kv_namespaces ?? []),
{ id: binding.namespace_id, binding: binding.name },
];
}
break;
case "durable_object_namespace":
{
configObj.durable_objects = {
bindings: [
...(configObj.durable_objects?.bindings ?? []),
{
name: binding.name,
class_name: binding.class_name,
script_name: binding.script_name,
environment: binding.environment,
},
],
};
}
break;
case "d1":
{
configObj.d1_databases = [
...(configObj.d1_databases ?? []),
{
binding: binding.name,
database_id: binding.id,
database_name: d1BindingsWithInfo[binding.id].name,
},
];
}
break;
case "browser":
{
configObj.browser = {
binding: binding.name,
};
}
break;
case "ai":
{
configObj.ai = {
binding: binding.name,
};
}
break;
case "r2_bucket":
{
configObj.r2_buckets = [
...(configObj.r2_buckets ?? []),
{
binding: binding.name,
bucket_name: binding.bucket_name,
jurisdiction: binding.jurisdiction,
},
];
}
break;
case "service":
{
configObj.services = [
...(configObj.services ?? []),
{
binding: binding.name,
service: binding.service,
environment: binding.environment,
entrypoint: binding.entrypoint,
},
];
}
break;
case "analytics_engine":
{
configObj.analytics_engine_datasets = [
...(configObj.analytics_engine_datasets ?? []),
{ binding: binding.name, dataset: binding.dataset },
];
}
break;
case "dispatch_namespace":
{
configObj.dispatch_namespaces = [
...(configObj.dispatch_namespaces ?? []),
{
binding: binding.name,
namespace: binding.namespace,
...(binding.outbound && {
outbound: {
service: binding.outbound.worker.service,
environment: binding.outbound.worker.environment,
parameters:
binding.outbound.params?.map((p) => p.name) ?? [],
},
}),
},
];
}
break;
case "logfwdr":
{
configObj.logfwdr = {
bindings: [
...(configObj.logfwdr?.bindings ?? []),
{ name: binding.name, destination: binding.destination },
],
};
}
break;
case "wasm_module":
{
configObj.wasm_modules = {
...(configObj.wasm_modules ?? {}),
[binding.name]: binding.part,
};
}
break;
case "text_blob":
{
configObj.text_blobs = {
...(configObj.text_blobs ?? {}),
[binding.name]: binding.part,
};
}
break;
case "data_blob":
{
configObj.data_blobs = {
...(configObj.data_blobs ?? {}),
[binding.name]: binding.part,
};
}
break;
default: {
// If we don't know what the type is, its an unsafe binding
// eslint-disable-next-line @typescript-eslint/no-explicit-any
if (!(binding as any)?.type) {
break;
}
configObj.unsafe = {
bindings: [...(configObj.unsafe?.bindings ?? []), binding],
metadata: configObj.unsafe?.metadata ?? undefined,
};
}
}

Please provide a link to a minimal reproduction

No response

Please provide any relevant error logs

No response

@KianNH KianNH added the bug Something that isn't working label Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant