Skip to content

synthesize_manifest produces invalid TOML when appending a synthesized license field #315

Description

@yu7400ki

Description

When a manifest contains a [package] table but no blank line or subsequent table is found, synthesize_manifest appends the synthesized license field at the end of the manifest.

The append branch writes the opening quote but not the closing quote:

existing.push_str("license = \"");
let offset = existing.len();
writeln!(&mut existing, "{expression}\n").unwrap();

As a result, the synthesized manifest is invalid TOML:

[package]
name = "example"
version = "0.1.0"
license = "MIT

This was introduced in #299, which replaced the previous toml_edit implementation with manual string manipulation.

Expected behavior

The synthesized license value should be valid TOML and include its closing quote.

Suggested fix

Write the closing quote as part of the formatted line:

existing.push_str("license = \"");
let offset = existing.len();
writeln!(&mut existing, "{expression}\"").unwrap();

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions