Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Common base class for CEL exceptions, without breaking the existing builtin mappings

Open
#49 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
python, rust

Research direction

Start by inspecting python/cel/exceptions.py, map_execution_error_to_python, cel.pyi, and the error-handling how-to. Trace the existing execution and parse error mappings, then verify that the new hierarchy preserves builtin exception handling, supports catching cel.CelError, and is documented in the stub and how-to table.

Written by the indexing model from the issue text.

Description

enhancement

Follow-up promised when closing #23. Execution errors are mapped to the idiomatic builtin (RuntimeError, TypeError, KeyError, IndexError, ZeroDivisionError, OverflowError) and parse errors to ValueError, which is right for each case but means "did the rule run and fail" needs a five-clause except:

except (RuntimeError, TypeError, KeyError, IndexError, ArithmeticError):

Proposal

Add a cel.CelError hierarchy whose members also inherit from the builtin they replace, so nothing existing breaks:

class CelError(Exception): ...
class CelParseError(CelError, ValueError): ...
class CelRuntimeError(CelError, RuntimeError): ...
class CelTypeError(CelError, TypeError): ...
class CelKeyError(CelError, KeyError): ...
class CelIndexError(CelError, IndexError): ...
class CelZeroDivisionError(CelError, ZeroDivisionError): ...
class CelOverflowError(CelError, OverflowError): ...

except TypeError keeps working; except cel.CelError catches everything CEL raised; except cel.CelParseError separates a bad rule from a failed check.

Implementation notes

PyO3's create_exception! only takes a single base, so define the classes in a small python/cel/exceptions.py and have map_execution_error_to_python look them up from the module once (a GILOnceCell<Py<PyType>> per class) and raise with PyErr::from_type. Add them to cel.pyi and to the error-handling how-to, whose current table becomes the mapping between the two hierarchies.

Dominant language
Python
Stars
43
Forks
4
Avg merge
9h 57m
Merged PRs (30d)
14

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from hardbyte/python-common-expression-language

All issues in hardbyte/python-common-expression-language

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.