Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions runtime/parser/parse_component.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"

runtimev1 "github.com/rilldata/rill/proto/gen/rill/runtime/v1"
"github.com/rilldata/rill/runtime/pkg/pbutil"
"google.golang.org/protobuf/types/known/structpb"
)

Expand All @@ -29,9 +30,9 @@ func (y *ComponentVariableYAML) Proto() (*runtimev1.ComponentVariable, error) {
if y == nil {
return nil, fmt.Errorf("is empty")
}
val, err := structpb.NewValue(y.Value)
val, err := pbutil.ToValue(y.Value, nil)
if err != nil {
panic(fmt.Errorf("invalid default value: %w", err))
return nil, fmt.Errorf("invalid default value: %w", err)
}
return &runtimev1.ComponentVariable{
Name: y.Name,
Expand Down
37 changes: 37 additions & 0 deletions runtime/parser/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1885,6 +1885,43 @@ rows:
requireResourcesAndErrors(t, p, resources, nil)
}

func TestComponentInputDateValue(t *testing.T) {
// Regression test: yaml.v3 decodes a bare date like 2024-01-01 into a time.Time,
// which structpb.NewValue rejects and previously caused a panic that aborted the entire parse.
ctx := context.Background()
repo := makeRepo(t, map[string]string{
`rill.yaml`: ``,
`components/c1.yaml`: `
type: component
markdown:
content: "Hello"
input:
- name: start
type: string
value: 2024-01-01
`,
})

resources := []*Resource{
{
Name: ResourceName{Kind: ResourceKindComponent, Name: "c1"},
Paths: []string{"/components/c1.yaml"},
ComponentSpec: &runtimev1.ComponentSpec{
DisplayName: "C1",
Renderer: "markdown",
RendererProperties: must(structpb.NewStruct(map[string]any{"content": "Hello"})),
Input: []*runtimev1.ComponentVariable{
{Name: "start", Type: "string", DefaultValue: structpb.NewStringValue("2024-01-01T00:00:00Z")},
},
},
},
}

p, err := Parse(ctx, repo, "", "", "duckdb", true)
require.NoError(t, err)
requireResourcesAndErrors(t, p, resources, nil)
}

func TestCanvasTabGroups(t *testing.T) {
ctx := context.Background()
repo := makeRepo(t, map[string]string{
Expand Down
Loading