kornia/kornia-rs

[Bug]: augmentations.rs: dict_get panics on missing key instead of raising PyErr

Open

#1,058 opened on Jul 29, 2026

 (1 comment) (0 reactions) (0 assignees)Rust (188 forks)auto 404
bughelp wantedtriage

Repository metrics

Stars
 (675 stars)
PR merge metrics
 (PR metrics pending)

Description

🐛 Describe the bug

/// Extract a required key from a params dict. /// /// Panics on missing key to match the previous unwrap() behavior at each call site. fn dict_get<'py, T>(d: &Bound<'py, PyDict>, key: &str) -> PyResult where T: for<'a> FromPyObject<'a, 'py, Error = PyErr>, { d.get_item(key)?.unwrap().extract::() }

🔄 Steps to Reproduce

Despite the PyResult return signature, a missing key currently panics via .unwrap() rather than returning Err. This is used across the params= path of every transform's __call__ (RandomHorizontalFlip, RandomVerticalFlip, RandomCrop, RandomRotation, etc.) — a malformed or incomplete params dict supplied by user code crashes the interpreter thread instead of raising a catchable Python exception.

💻 Minimal Code Example

✅ Expected behavior

Location: apply_saturation_neon and apply_saturation_scalar (plus the fused-LUT helpers they support: build_linear_lut, apply_lut, byte_mean) live in kornia_imgproc (or kornia_image, whichever crate owns comparable pixel kernels like rgb_to_gray_u8), not in the augmentations.rs PyO3 bindings file. augmentations.rs calls into that crate the same way blur.rs calls filter::gaussian_blur_u8, color.rs calls color::rgb_from_gray, etc. — a thin marshalling wrapper only.

❌ Actual behavior

return Err(PyValueError::new_err(...)) on a missing key, naming the missing key and the transform.

🔧 Environment

- kornia-rs version:
- Rust version (`rustc -V`):
- Cargo version (`cargo -V`):
- OS (e.g., Linux, macOS, Windows):
- Target architecture (if cross-compiling):
- Python version (if using Python bindings):

📝 Additional context

No response

🤝 Contribution Intent

  • I plan to submit a PR to fix this bug
  • I'm reporting this bug but not planning to fix it

Contributor guide