vstakhov / libucl

Universal configuration library parser
BSD 2-Clause "Simplified" License
1.63k stars 140 forks source link

possible regression going from 0.8.2 to 0.9.0 #285

Closed dlangille closed 7 months ago

dlangille commented 7 months ago

I noticed this regression after upgrading from 0.8.2 to 0.9.0 today. The following is a simple example broken down from one of my use cases.

with 8.0.2:

% /usr/local/bin/ucl_tool --in test.ucl --format json
[
    {
        "type": "install",
        "message": "1) add webcamd_enable=\"YES\"\n\nto your /etc/rc.conf"
    }
]

With 0.9.0, we have additional commas:

% /usr/local/bin/ucl_tool --in test.ucl --format json
,
[
    ,
{
        "type": "install",
        "message": "1) add webcamd_enable=\"YES\"\n\nto your /etc/rc.conf"
    }
]

Source:

% cat test.ucl
[
{ type: install
  message: <<EOM
1) add webcamd_enable="YES"

to your /etc/rc.conf
EOM
}
]
Crest commented 7 months ago

I've been bitten by the same problem and 'blamed' uclcmd in FreeBSD PR #277666 (updated to link to this issue report).

The problem makes it impossible to use ucl_object_emit() YAML, JSON and compact JSON output format for anything but scalar UCL types (int, float, string boolean, time, and maybe user-data depending on the user-data). It breaks both arrays and objects. The YAML breakage is more subtle because of its significant whitespaces.

Crest commented 7 months ago

There is a fix for the emitter that was committed to the master branch after the latest (0.9.0) release: https://github.com/vstakhov/libucl/commit/da7aacb3d46fbc206ec6f2431f503eed843a3039.

vstakhov commented 7 months ago

Haven't I tagged that yet? Let me check...

Crest commented 7 months ago

I've already submitted a (FreeBSD) bug report with a patch against for the libucl port, because I didn't expect such a fast turnaround. I especially worry about what the YAML output could be parsed as because I'm not sure all outputs from libucl 0.9.0 are either syntactically invalid or preserve the document structure.

vstakhov commented 7 months ago

I have tagged the release 0.9.1 with the fix.

dlangille commented 7 months ago

Confirming, 0.9.1 fixes the issue for me. Thank you.