cloud-custodian / cloud-custodian/cel-python
Three-argument filtered map macro raises ValueError during evaluation
- 主要语言
- Python
- 星标
- 174
- 派生
- 40
- PR 合并指标
- 30 天内没有已合并 PR
描述
## Summary
The standard filtered `map(x, predicate, transform)` form compiles but raises `ValueError: too many values to unpack (expected 2)` during evaluation. The equivalent `filter(...).map(...)` expression completes normally.
## Reproduction
Save the following as `repro.py`.
```python
from celpy import Environment
for expression in (
"[1,2,3].map(x, x > 1, x+1)[0]",
"[1,2,3].filter(x, x > 1).map(x, x+1)[0]",
):
env = Environment()
try:
result = env.program(env.compile(expression)).evaluate({})
print(expression, "=>", result)
except Exception as exc:
print(expression, "=>", type(exc).__name__, str(exc))
```
Run:
```sh
python -m pip install cel-python==0.5.0
python repro.py
```
## Actual result
```text
[1,2,3].map(x, x > 1, x+1)[0] => ValueError too many values to unpack (expected 2)
[1,2,3].filter(x, x > 1).map(x, x+1)[0] => 3
```
## Expected behavior and why
Both expressions should return `3`: filter `[1,2,3]` to `[2,3]`, add one to each element, and select the first result.
CEL defines `e.map(x, p, t)` as the map transformation with predicate filtering before transformation:
https://github.com/cel-expr/cel-spec/blob/ba58ae5007845f3a1279b488cdeb79645ce958bb/doc/langdef.md#macros
## Code-level observation and impact
The map evaluator unpacks two macro arguments where this form supplies three. This is an internal Python arity error rather than the normal evaluation of a supported CEL expression. If this macro overload is intentionally outside the supported profile, please clarify that scope; accepting the syntax and then raising an unpacking error is still an unhelpful failure mode for callers.
## Environment
- Package: cel-python 0.5.0
- Runtime: CPython 3.13.3
- OS: macOS 26.6.2, Apple Silicon / arm64
- Reproduced: 2026-09-11
[cel-python-reproduction.zip](https://github.com/user-attachments/files/32164148/cel-python-reproduction.zip)
贡献指南
这个仓库没有索引到贡献指南
调研方向
首先,针对 map 宏求值器运行提供的 repro.py,并跟踪 issue 中描述的三参数过滤 map 路径。为两个表达式都添加覆盖测试,然后确认过滤形式返回 3,而不是引发 ValueError,同时现有的 filter(...).map(...) 形式仍然通过。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- python
- 领域
- backend
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 活跃
- 描述清晰度
- 基本清楚
- 新手友好度
- 68/100