Skip to content

fix(toml): fix empty string handling #6585

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

Merged
merged 1 commit into from
Apr 16, 2025

Conversation

timreichen
Copy link
Contributor

The current toml implementation throws when trying to parse an empty string.
(Probably) all toml npm implementations allow empty strings and return an empty object, so we should probably too.

import toml from "npm:toml";
assertEquals(toml.parse(""), {});

import tomljs from "npm:toml-js";
assertEquals(tomljs.parse(""), {});

import * as s from "npm:smol-toml";
assertEquals(s.parse(""), {});

import * as i from "npm:@iarna/toml";
assertEquals(i.parse(""), {});

import * as c from "npm:confbox";
assertEquals(c.parseTOML(""), {});

@timreichen timreichen requested a review from kt3k as a code owner April 15, 2025 12:24
@github-actions github-actions bot added the toml label Apr 15, 2025
Copy link

codecov bot commented Apr 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 94.58%. Comparing base (3a021b2) to head (9226dd5).
Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6585   +/-   ##
=======================================
  Coverage   94.58%   94.58%           
=======================================
  Files         579      579           
  Lines       43752    43752           
  Branches     6494     6494           
=======================================
+ Hits        41381    41383    +2     
+ Misses       2331     2329    -2     
  Partials       40       40           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@kt3k kt3k changed the title BREAKING(toml): fix empty string bug fix(toml): fix empty string bug Apr 16, 2025
@kt3k kt3k changed the title fix(toml): fix empty string bug fix(toml): fix empty string handling Apr 16, 2025
Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like empty string should be mapped to {} according to the spec maintainer. toml-lang/toml#607

LGTM

I don't think this is a breaking change. I changed the commit type to 'fix'. (A breaking change is an intentional design change, which breaks the users' code. The existing behavior is unintentional bug.)

@kt3k kt3k merged commit 0019daa into denoland:main Apr 16, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants