Skip to content

internal/cuegen incompatible with cuelang.org/go v0.16.0 #404

@mjrossi

Description

@mjrossi

Overview

The internal/cuegen/cue.go file uses ast.Field.Optional (a token.Pos), which was removed in cuelang.org/go v0.16.0. The field was replaced with ast.Field.Constraint (a token.Token), where token.OPTION represents an optional field.

This causes a compilation error when a downstream project's dependency graph pulls in CUE v0.16.0:

  vendor/github.com/redpanda-data/benthos/v4/internal/cuegen/cue.go:171:3:
    unknown field Optional in struct literal of type ast.Field

Affected Code

The affected code is in doScalarField():

return &ast.Field{
    Label:    label,
    Value:    val,
    Optional: optional,  // no longer exists in cuelang.org/go v0.16.0
}, nil

The new CUE API equivalent would be:

  return &ast.Field{
      Label:      label,
      Value:      val,
      Constraint: token.OPTION,  // when the field should be optional
  }, nil

Reproduction

  1. In a Go project that depends on benthos/v4, update cuelang.org/go to v0.16.0
  2. Run go build ./... (or golangci-lint)
  3. Compilation fails with the error above

Versions

  • cuelang.org/go v0.16.0 (breaking change)
  • benthos v4.68.0 (latest, still pins CUE v0.15.4)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions