puppetlabs / puppetlabs/puppetlabs-stdlib

stdlib::to_toml behaves differently on dotted keys compared to TOML::Generator

Open
#1,452 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
349
Forks
573
Avg merge
3d 3h
Merged PRs (30d)
1

Description

Describe the Bug

TOML supports "dotted keys", that is about the same as our "dotted notation" when accessing facts.
Our stdlib::to_toml() uses toml-rb code, that has the issue when dealing with dotted keys.

I hit this when following the puppet-grafana's LDAP config example. It uses toml gem at the moment. When replaced with stdlib::to_toml() it produces a broken TOML.

As I see from unit tests, to_toml() expects a proper Puppet DSL Hash, while toml gem can work with dotted keys.

As a consequence, it's impossible to just replace TOML::Generator with our to_toml() function, because example syntax uses dotted key instead of a nested Hash or Array.

Another problem is sections reordering. E.g. [servers.attributes] section goes before [[servers]], which is wrong.

Expected Behavior

  1. It'd be nice if dotted keys wouldn't be quoted.
  2. It'd be nice if sections wouldn't be reordered.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the stdlib::to_toml implementation and its unit tests, then compare its output with TOML::Generator for dotted keys and sections. Reproduce the puppet-grafana LDAP example and verify that dotted keys are not quoted and that sections retain the required ordering.

Written by the indexing model from the issue text.

Assessment

Tech stack
ruby
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.