OSIS generator: service method wrapper naming collision across services #12

Open
opened 2026-03-27 00:52:46 +00:00 by mik-tf · 0 comments
Owner

Problem

The OSIS code generator creates convenience wrapper methods on the domain struct using only the method name without a service prefix. When multiple services define methods with the same name (list, create, get, etc.), the generated code has duplicate method definitions that don't compile.

Example:

// Generated — both on OsisFreezone impl:
pub fn list(&self, user_id: String, ...) -> ... // from CompanyService
pub fn list(&self, fzc_id: String, ...) -> ...  // from InvoiceService
// ERROR: duplicate definitions

Location

hero_rpc/crates/generator/src/rust/rust_osis.rs — the method generation doesn't prefix with the service name.

Suggested Fix

Prefix generated convenience methods with the service name:

// Instead of:
pub fn list(...)

// Generate:
pub fn companyservice_list(...)
pub fn invoiceservice_list(...)

Or generate them in a service-scoped impl block or module.

Current Workaround

In the freezone project, we removed the convenience methods entirely from the generated code and use qualified RPC dispatch (contractservice.sign_contract via handle_rpc()). This works but means the type-safe convenience methods aren't available.

See: znzfreezone_code/home#34

Impact

Any project with multiple services that have overlapping method names hits this. The workaround (removing convenience methods) is functional but loses the ergonomic API.

## Problem The OSIS code generator creates convenience wrapper methods on the domain struct using only the method name without a service prefix. When multiple services define methods with the same name (`list`, `create`, `get`, etc.), the generated code has duplicate method definitions that don't compile. **Example:** ```rust // Generated — both on OsisFreezone impl: pub fn list(&self, user_id: String, ...) -> ... // from CompanyService pub fn list(&self, fzc_id: String, ...) -> ... // from InvoiceService // ERROR: duplicate definitions ``` ## Location `hero_rpc/crates/generator/src/rust/rust_osis.rs` — the method generation doesn't prefix with the service name. ## Suggested Fix Prefix generated convenience methods with the service name: ```rust // Instead of: pub fn list(...) // Generate: pub fn companyservice_list(...) pub fn invoiceservice_list(...) ``` Or generate them in a service-scoped impl block or module. ## Current Workaround In the freezone project, we removed the convenience methods entirely from the generated code and use qualified RPC dispatch (`contractservice.sign_contract` via `handle_rpc()`). This works but means the type-safe convenience methods aren't available. See: https://forge.ourworld.tf/znzfreezone_code/home/issues/34 ## Impact Any project with multiple services that have overlapping method names hits this. The workaround (removing convenience methods) is functional but loses the ergonomic API.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_rpc#12
No description provided.