Skip to content

feat(core): centralize snake_to_camel and fix FFI casing leakage#446

Merged
Goldziher merged 7 commits intomainfrom
feat/centralized-casing-ffi
Mar 8, 2026
Merged

feat(core): centralize snake_to_camel and fix FFI casing leakage#446
Goldziher merged 7 commits intomainfrom
feat/centralized-casing-ffi

Conversation

@kh3rld
Copy link
Contributor

@kh3rld kh3rld commented Mar 7, 2026

just implemented a centralized solution for the snake_case leakage observed across multiple language bindings (Node.js, Go, Java, C#). Instead of fixing casing in each bridge individually, this PR moves the transformation logic into the Rust core and applies it at the FFI layer.

changes:

  • Core Strategy: Created crates/kreuzberg/src/utils/json_utils.rs containing a robust recursive snake_to_camel utility for serde_json::Value.
  • FFI Fix: Updated crates/kreuzberg-ffi/src/helpers.rs to apply this transformation to the metadata JSON. This ensures that any consumer of the C FFI (Go, Java, C#) automatically receives camelCase metadata.
  • Node.js Refactor: Simplified crates/kreuzberg-node/src/result.rs by removing the redundant local implementation and using the core utility.
  • Verification: Added comprehensive unit tests for the transformation logic in the core crate.

@kh3rld kh3rld requested a review from Goldziher March 7, 2026 11:14
@kh3rld kh3rld added enhancement New feature or request rust Pull requests that update rust code labels Mar 7, 2026
CHANGELOG.md Outdated

### Added

- **Centralized FFI metadata casing**: Moved `snake_to_camel` recursive JSON transformation logic into the Rust core (`kreuzberg::utils::json_utils`) and applied it to the FFI layer (`kreuzberg-ffi`). This ensures all metadata returned via FFI (used by Go, Java, C#, etc.) consistently uses `camelCase` for dynamic fields.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This doesn't go into the changelog. Only user facing changes go into this .

This PR is a refactor, wholly internal.

@Goldziher Goldziher merged commit 33656d8 into main Mar 8, 2026
81 of 88 checks passed
@Goldziher Goldziher deleted the feat/centralized-casing-ffi branch March 8, 2026 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request rust Pull requests that update rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants