Skip to content

Conversation

@hardbyte
Copy link
Owner

Summary

  • vendor the cel interpreter crate and introduce a MapValue trait so maps can be backed by dynamic sources
  • wrap Python mapping objects in a new PyMappingValue and surface them to CEL without eagerly copying entries
  • add a regression test to ensure dict subclasses with lazy __getitem__ calls are evaluated correctly

Testing

  • cargo test (fails: missing libpython3.11.so.1.0 in test harness)
  • pytest (fails: environment lacks installed cel package and mktestdocs dependency)

https://chatgpt.com/codex/tasks/task_b_68ede34e85148329ad0078eeea94b756

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting

Comment on lines +138 to +145
fn get(&self, key: &Key) -> Option<Value> {
Python::with_gil(|py| {
let bound = self.mapping.bind(py);
let mapping = bound.downcast::<PyMapping>().ok()?;
let py_key = Self::key_to_python(py, key);
let value = mapping.get_item(py_key).ok()?;
RustyPyType(&value).try_into_value().ok()
})

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Propagate conversion errors in lazy mappings

When a value in a lazy Python mapping fails to convert into a CEL Value, PyMappingValue::get returns None and the evaluator treats the access as a missing key (null). This silently discards the underlying Python exception, whereas the previous eager conversion of PyDict raised a ConversionError immediately. A dict subclass that yields an unsupported object for data["foo"] will now evaluate to null instead of raising, making bad data hard to detect. It would be better to surface the conversion failure (e.g., by raising or logging) rather than swallowing it as an absent key.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants