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

🚀 Feature Request: improve the wrangler.toml config experience #1165

Closed
IgorMinar opened this issue Jun 1, 2022 · 3 comments
Closed

🚀 Feature Request: improve the wrangler.toml config experience #1165

IgorMinar opened this issue Jun 1, 2022 · 3 comments
Labels
enhancement New feature or request

Comments

@IgorMinar
Copy link
Contributor

IgorMinar commented Jun 1, 2022

Describe the solution

A feedback that often comes up in various discussions is that the toml config file is not ergonomic, error-prone, and generally unpleasant to use.

There are at least three different root causes behind this pain:

  • there are inherent issues specific to toml syntax/spec (sample writeup of common issues)
  • we provide only limited validation of the wrangler.toml file (see example file that passes validation when it shouldn't)
  • most Web developers are not familiar with the toml format, json (and even yaml) are used much more commonly

We could improve the validation of the toml file (interesting schema-based validator: https://json-schema-everywhere.github.io/toml), but we might as well consider using alternative format altogether.

One alternative to consider is JSON with comments. This format is very popular format (used by TypeScript, Angular, and many others), has great tooling support for validation, formatting, syntax highlighting, docs generation.

In order to smooth out the transition if we do adopt an alternative format, we should also make it easy for people to convert the existing toml file to the new format. This could be a built-in functionality of Wrangler — we could for example automatically prompt the dev and offer the config file to be converted if they are still using toml.

I've seen some people ask for js based config language. While there is a space for imperative Wrangler API for general configuration, it is generally much more preferable to stick with declarative languages for configuration because those are more suitable for long-term evolution (via automated config transformation) and are significantly easier to integrate with other tooling (like IDEs) which otherwise would need to execute untrusted code in order to read the config.


example of a toml file that passes validation, and critical config property to be ignored during deployment:

name = "test"
main = "src/index.ts"

[[durable_objects.bindings]]
name = "test"
class_name = "Test"

[[migrations]]
tag = "v1"
new_classes = ["Test"]

compatibility_date = "2022-05-16"

The compatibility_date property is ignored when it shouldn't be.

@IgorMinar IgorMinar added the enhancement New feature or request label Jun 1, 2022
threepointone added a commit that referenced this issue Jun 1, 2022
This adds a warning for unexpected fields on `[migrations]` config, reported in #1165. It also adds a test for incorrect `renamed_classes` in a migration.
@threepointone
Copy link
Contributor

Yeah, we want to change the format (or rather, accept multiple formats), we just haven't gotten around to it yet. Of note with this specific example tho, is that we do log a warning for a missing compatibility_date, so it's not completely silent. We were missing validation for unexpected fields in migrations, fix at #1166

@petebacondarwin petebacondarwin moved this to Untriaged in workers-sdk Jun 2, 2022
@petebacondarwin petebacondarwin moved this from Untriaged to Backlog in workers-sdk Jun 2, 2022
threepointone added a commit that referenced this issue Jun 2, 2022
This adds a warning for unexpected fields on `[migrations]` config, reported in #1165. It also adds a test for incorrect `renamed_classes` in a migration.
@IgorMinar
Copy link
Contributor Author

Supporting multiple formats often becomes a big headache because of increased maintenance and support cost (bugs, extra design time needed for new config keys, extra documentation needed). If we could just land on a single format (or temporarily, during a migration, support two formats) then that would be preferable.

@penalosa penalosa closed this as completed Oct 7, 2022
Repository owner moved this from Backlog to Done in workers-sdk Oct 7, 2022
@penalosa
Copy link
Contributor

penalosa commented Oct 7, 2022

Closing in favour of #1951

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants