Skip to content

Panic when upgrading to prettier-plugin-toml v2.0.4 #452

@hyperupcall

Description

@hyperupcall

Thanks for maintaining prettier-plugin-toml! We use it at SchemaStore for formatting TOML files.

When upgrading to v2.0.4 (not on v2.0.3), we encountered a panic:

prettier.................................................................Failed
- hook id: prettier
- exit code: 2

panicked at /Users/JounQin/Workspaces/GitHub/taplo/crates/taplo/src/formatter/mod.rs:684:25:
assertion failed: entry.comment.is_none()

Stack:

Error
    at I.wbg.__wbg_new_abda76e883ba8a5f (/home/runner/.cache/pre-commit/repoghj_9a00/node_env-system/lib/node_modules/prettier-plugin-toml/node_modules/@taplo/lib/dist/index.js:2:4161)
    at console_error_panic_hook::Error::new::hd83448d5e1a1b88a (wasm://wasm/065ed00a:wasm-function[40242]:0x[12](https://github.com/SchemaStore/schemastore/actions/runs/14921130855/job/41916573707?pr=4694#step:5:13)49bc2)
    at console_error_panic_hook::hook_impl::h24434d5d3a31a46a (wasm://wasm/065ed00a:wasm-function[10411]:0xcf17fe)
    at console_error_panic_hook::hook::hb562c91cafc2c895 (wasm://wasm/065ed00a:wasm-function[59765]:0x12e59c7)
    at core::ops::function::Fn::call::h46d6beedf89bee9d (wasm://wasm/065ed00a:wasm-function[42879]:0x1275769)
    at std::panicking::rust_panic_with_hook::h8e8556df5e46d2ff (wasm://wasm/065ed00a:wasm-function[20551]:0xfc8712)
    at std::panicking::begin_panic_handler::{{closure}}::h142b9f459ded72d9 (wasm://wasm/065ed00a:wasm-function[25954]:0x10c54b9)
    at std::sys_common::backtrace::__rust_end_short_backtrace::h1c0d3278570375be (wasm://wasm/065ed00a:wasm-function[61550]:0x12e9f20)
    at rust_begin_unwind (wasm://wasm/065ed00a:wasm-function[42801]:0x12744d7)
    at core::panicking::panic_fmt::hbea4287e435ed8a3 (wasm://wasm/065ed00a:wasm-function[43645]:0x1280e86)


Error:  src/test/pyproject/pdm_tool.toml: Error: RuntimeError: unreachable
Error:      at M.format (/home/runner/.cache/pre-commit/repoghj_9a00/node_env-system/lib/node_modules/prettier-plugin-toml/node_modules/@taplo/lib/dist/index.js:2:35638065)
Error:      at format (file:///home/runner/.cache/pre-commit/repoghj_9a00/node_env-system/lib/node_modules/prettier-plugin-toml/lib/index.js:10:21)
Error:      at Object.parse (file:///home/runner/.cache/pre-commit/repoghj_9a00/node_env-system/lib/node_modules/prettier-plugin-toml/lib/index.js:17:24)
Error:      at parse5 (file:///home/runner/.cache/pre-commit/repoghj_9a00/node_env-system/lib/node_modules/prettier/index.mjs:19983:24)
Error:      at async coreFormat (file:///home/runner/.cache/pre-commit/repoghj_9a00/node_env-system/lib/node_modules/prettier/index.mjs:20531:25)
Error:      at async formatWithCursor (file:///home/runner/.cache/pre-commit/repoghj_9a00/node_env-system/lib/node_modules/prettier/index.mjs:20743:14)
Error:      at async formatFiles (file:///home/runner/.cache/pre-commit/repoghj_9a00/node_env-system/lib/node_modules/prettier/internal/cli.mjs:42[13](https://github.com/SchemaStore/schemastore/actions/runs/14921130855/job/41916573707?pr=4694#step:5:14):18)
Error:      at async main (file:///home/runner/.cache/pre-commit/repoghj_9a00/node_env-system/lib/node_modules/prettier/internal/cli.mjs:4865:5)
Error:      at async Module.run (file:///home/runner/.cache/pre-commit/repoghj_9a00/node_env-system/lib/node_modules/prettier/internal/cli.mjs:4811:5)

codespell................................................................Passed
Error: Process completed with exit code 1.

The pdm_tool.toml file:

SHOW
#:schema ../../schemas/json/pyproject.json
[tool.pdm]
plugins = ["sync-pre-commit-lock"]
distribution = false
ignore_package_warnings = [
  "scipy",
  "tensorflow-*",
] # https://pdm-project.org/latest/usage/config/#ignore-package-warnings

[tool.pdm.dev-dependencies] # https://pdm-project.org/latest/usage/dependency/#add-development-only-dependencies
dev = ["pytest>=7.4.3"]
lint = ["mypy>=1.7.1"]

[tool.pdm.resolution] # https://pdm-project.org/latest/usage/config/#respect-the-order-of-the-sources
allow-prereleases = true    # https://pdm-project.org/latest/usage/config/#allow-prereleases-in-resolution-result
respect-source-order = true
excludes = ["tensorflow"]

[tool.pdm.resolution.overrides] # https://pdm-project.org/latest/usage/config/#override-the-resolved-package-versions
asgiref = "3.2.10"                                                # exact version
urllib3 = ">=1.26.2"                                              # version range
pytz = "https://mypypi.org/packages/pytz-2020.9-py3-none-any.whl" # absolute URL

[tool.pdm.options] # https://pdm-project.org/latest/usage/config/#passing-constant-arguments-to-every-pdm-invocation
add = ["--no-isolation", "--no-self"]
install = ["--no-self"]
lock = ["--no-cross-platform"]

[[tool.pdm.source]] # https://pdm-project.org/latest/usage/config/#configure-the-package-indexes
name = "private"
url = "https://private.pypi.org/simple"
verify_ssl = true
type = "index"
include_packages = [
  "foo",
  "foo-*",
] # https://pdm-project.org/latest/usage/config/#specify-index-for-individual-packages

[tool.pdm.scripts] # https://pdm-project.org/latest/usage/scripts/
_.env_file = ".env"                                    # https://pdm-project.org/latest/usage/scripts/#shared-options
start.cmd = "flask run -p 54321"
start.env = { FOO = "bar", FLASK_ENV = "development" }
start.env_file = ".env"
start.help = "Start the server"

start1 = { cmd = "flask run -p 54321", env_file = { override = ".env" } }

start2 = { cmd = [
  "flask",
  "run",
  # Important comment here about always using port 54321
  "-p",
  "54321",
], env = { FOO = "bar", FLASK_ENV = "development" } }
filter_error = { shell = "cat error.log|grep CRITICAL > critical.log" }
foobar = { call = "foo_package.bar_module:main" }
foobar1 = { call = "foo_package.bar_module:main('dev')" }
lint = "flake8"
test = "pytest"
all = { composite = ["lint", "test"] }
all1 = { composite = ["lint mypackage/", "test -v tests/"] }

[tool.pdm.version] # https://backend.pdm-project.org/metadata/#dynamic-project-version
source = "scm"
tag_regex = '^(?:\D*)?(?P<version>([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*((a|b|c|rc)(0|[1-9][0-9]*))?(\.post(0|[1-9][0-9]*))?(\.dev(0|[1-9][0-9]*))?$)$'
write_to = "foo/_version.py"
write_template = "__version__ = '{}'"

[tool.pdm.build] # https://backend.pdm-project.org/build_config/#specify-the-package-files
includes = ["mypackage/", "script.py"]
excludes = ["**/*.json"]
source-includes = ["scripts/", "tests/"]
package-dir = "mysrc"
run-setuptools = false                   # https://backend.pdm-project.org/build_config/#run-setuptools
is-purelib = true                        # https://backend.pdm-project.org/build_config/#is-purelib
editable-backend = "path"                # https://backend.pdm-project.org/build_config/#choose-the-editable-build-format
custom-hook = "build.py"                 # https://backend.pdm-project.org/build_config/#local-build-hooks

[tool.pdm.build.wheel-data] # https://backend.pdm-project.org/build_config/#wheel-data-files
# Install all files under scripts/ to the $prefix/bin directory
scripts = ["scripts/*"]
# Install all files under include/ to the $prefix/include directory recursively, keeping the directory structure
include = [{ path = "include/**/*.h", relative-to = "include/" }]

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