Skip to content

🐛 BUG: Better handling of dates in wrangler.toml environment variables #7755

@vicb

Description

@vicb

Which Cloudflare product(s) does this pertain to?

Wrangler

What versions are you using?

3.101.0

What operating system and version are you using?

Mac

Please provide a link to a minimal reproduction

No response

Describe the Bug

If you have a wrangler.toml as follow:

[vars]
DATE = 2024-01-01
NUMBER = 2024

You will get an error (see below).

The most relevant parts are:

Your worker has access to the following bindings:
- Vars:
  - DATE: "2024-01-01"

[...]

✘ [ERROR] Unexpected options passed to `new Miniflare()` constructor:

Note that - DATE: "2024-01-01" is misleading/wrong.

The root cause it that toml has a Date type and DATE = 2024-01-01 parses as a date.

I think we should error early and with an helpful error message when a Date value is detected.

Please provide any relevant error logs

 ⛅️ wrangler 3.101.0
--------------------

Your worker has access to the following bindings:
- Vars:
  - DATE: "2024-01-01"
  - NUMBER: 2024
⎔ Starting local server...

✘ [ERROR] Unexpected options passed to `new Miniflare()` constructor:

  {
    ...,
    workers: [
      /* [0] */ {
        ...,
        bindings: {
          DATE: 2024-01-01T00:00:00.000Z { isDate: true },
                ^ Expected string, received date
                  Expected number, received date
                  Expected boolean, received date
                  Expected null, received date
                  Expected array, received date
                  Expected object, received date
          ...,
        },
        ...,
      },
      ...,
    ],
  }

Metadata

Metadata

Labels

error-messagingImproving user facing error messageswranglerRelating to the Wrangler CLI tool

Type

No fields configured for Bug.

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions