Skip to content

Prevent type-checking of a message create expression with a type variable #1135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
2 tasks
l46kok opened this issue Feb 21, 2025 · 0 comments
Open
2 tasks

Comments

@l46kok
Copy link
Collaborator

l46kok commented Feb 21, 2025

Describe the bug
An expression of the following form will type-check just fine, if the identifier x is declared as a type containing a struct type reference to a fully qualified protobuf message name:

x{ auth: google.rpc.context.AttributeContext.Auth{} }
env, err := cel.NewEnv(
	cel.Types(&rpcpb.AttributeContext_Request{}),
)
provider := env.CELTypeProvider()
attributeCtxType, _ := provider.FindStructType("google.rpc.context.AttributeContext.Request")
env, err = env.Extend(
	cel.Variable("x", attributeCtxType),
)

ast, _ := env.Compile(`x{ auth: google.rpc.context.AttributeContext.Auth{} }`)

To Reproduce
Check which components this affects:

  • parser
  • [ x ] checker
  • interpreter

Expected behavior
No runtimes across all CEL stacks can consume this AST to produce a new message, nor is it planned to do so. Type-checker should be made to explicitly fail in this scenario.

Additional context
java xref b/398261303

The issue is less pronounced in CEL-Go, since it requires an additional step of declaring the type variable fetched from a type provider, but the issue is still present nonetheless.

@l46kok l46kok changed the title Prevent type-checking of a message create expression with a type identifier Prevent type-checking of a message create expression with a type variable Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant