Skip to content

NativeTypes from ext doesn't honor ref.Val.Type #1223

@gudvinr

Description

@gudvinr

Describe the bug

When using ext.NativeTypes together with proto-mapped or manually mapped types as fields, it will try to map them as native types ignoring the fact they implement ref.Val and already exist in type provider.

To Reproduce
Check which components this affects:

  • parser
  • checker
  • interpreter

Sample expression and input that reproduces the issue:

ip("127.0.0.1") == conn.addr

Test setup:

package xfiles

import "k8s.io/apiserver/pkg/cel/library"

type Conn struct {
    Addr library.IP `cel:"addr"`
}

...

env, err := NewEnv(
    library.IP(),
    ext.NativeTypes(
        ext.ParseStructTag("cel"),
        reflect.TypeFor[*Conn](),
    ),
)

When you execute an expression, CEL will complain about missing overload for library.IP.

Expected behavior

conn.addr gets resolved into net.IP (i.e. library.IPType) and expression works as expected.

Additional context
Add any other context about the problem here.

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