What you will do
You will run the prepared expression in the playground above, change one input at a time, and explain the result. Start in CEL only, then repeat the same rule in CEL + JSON.
How it works
A list is an ordered collection. CEL indexes lists from zero: index 0 is the first item, 1 is the second, and so on. The index must be an int, and reading past the end is an error rather than a null result.
Read the prepared example
The CEL + JSON rule is:
items[1]Its input is:
{
"items": ["draft", "review", "approved"]
}The CEL only tab contains the values and the rule in one expression. The enabled cel.bind() extension keeps each name local to its final argument.
Evaluation step by step
itemscontains three strings in a fixed order.- Index
1selects the second position. - The result is
"review".
Your task
- Run the example.
- Change the index to
0, then to2. - Try index
3, read the range error, and restore1.
Expected observation: Indexes 0, 1, and 2 return the three items; index 3 is outside the list.
Common mistake
Do not confuse the number of items with the last valid index. A list of size 3 ends at index 2.
Show the explanation
4.
Knowledge check
What is the last valid index of a list whose size is 5?
Key takeaway
List order is stable, indexing starts at zero, and invalid access is an explicit error.
Sources
CEL-DEV— official CEL overview.CEL-LANG— official CEL language definition.CEL-GO-BIND— official documentation for the optionalcel.bind()extension used by the self-contained tab.