cue-lang / cue

The home of the CUE language! Validate and define text-based and dynamic configuration
https://cuelang.org
Apache License 2.0
5.02k stars 287 forks source link

encoding/toml: Import fails with `unknown DateTime` error #3345

Closed qjcg closed 5 days ago

qjcg commented 1 month ago

I tried cue import with the basic TOML example from the landing page of the official TOML website, and it failed with an unknown Datetime error (details below).

What version of CUE are you using (cue version)?

$ cue version
cue version v0.10.0-alpha.2.0.20240730115453-9b91188ea551

go version go1.22.5
      -buildmode exe
       -compiler gc
     CGO_ENABLED 1
          GOARCH amd64
            GOOS linux
         GOAMD64 v1
cue.lang.version v0.10.0

Does this issue reproduce with the latest stable release?

N/A

What did you do?

exec cue import example.toml

-- example.toml --
# This is a TOML document

title = "TOML Example"

[owner]
name = "Tom Preston-Werner"
dob = 1979-05-27T07:32:00-08:00

[database]
enabled = true
ports = [ 8000, 8001, 8002 ]
data = [ ["delta", "phi"], [3.14] ]
temp_targets = { cpu = 79.5, case = 72.0 }

[servers]

[servers.alpha]
ip = "10.0.0.1"
role = "frontend"

[servers.beta]
ip = "10.0.0.2"
role = "backend"

What did you expect to see?

No error, an example.cue successfully created via the cue import command.

What did you see instead?

$ testscript test_toml_import.txtar 
> exec cue import example.toml
[stderr]
encoding/toml.Decoder.decodeExpr: unknown DateTime &unstable.Node{Kind:15, Raw:unstable.Range{Offset:0x0, Length:0x0}, Data:[]uint8{0x31, 0x39, 0x37, 0x39, 0x2d, 0x30, 0x35, 0x2d, 0x32, 0x37, 0x54, 0x30, 0x37, 0x3a, 0x33, 0x32, 0x3a, 0x30, 0x30, 0x2d, 0x30, 0x38, 0x3a, 0x30, 0x30}, next:-1, child:0}
[exit status 1]
FAIL: /tmp/testscript2668849915/test_toml_import.txtar/script.txtar:1: unexpected command failure
error running test_toml_import.txtar in /tmp/testscript2668849915/test_toml_import.txtar
mvdan commented 1 month ago

ah, datetimes aren't supported just yet, they are a TODO in the code :) thanks for reporting.