test(rpc,core,billing,team): harden registry + RPC helpers with edge-case coverage#786
Conversation
…tracts Adds unit coverage to modules that currently gate RPC correctness but had weak or zero test coverage: - src/rpc/mod.rs: RpcOutcome::new, single_log, and into_cli_compatible_json — verify the CLI envelope shape switches on log presence, log order is preserved, empty-string logs still trigger the envelope, and null values round-trip unwrapped when there are no logs. - src/core/dispatch.rs: core.ping / core.version routing, unknown-method error surface, empty-method handling, tier-2 delegation to rpc::try_dispatch, and exact-match semantics of try_core_dispatch. - src/core/mod.rs: ControllerSchema::method_name formatting, drift guard against rpc_method_name, JSON serialization shape, and PartialEq behavior for FieldSchema/TypeSchema nesting. - src/core/jsonrpc.rs: params_to_object shape errors (array/string/number), type_name per variant, parse_json_params success + error text, is_session_expired_error matching rules (401+unauthorized, invalid token, SESSION_EXPIRED sentinel), escape_html coverage, and invoke_method rejection of array/string params for registered methods.
…t validation Second batch hardening the Rust core/RPC surface: - src/core/all.rs: validate_params edge cases (optional present/absent, missing-required error carries comment + namespace.function, missing-required fires before unknown-param, null values satisfy presence check); validate_registry edge cases (empty/whitespace namespace, empty function, declared-without-registered, registered-without-declared, duplicate registered controllers); try_invoke_registered_rpc None/Some routing; global registry consistency invariant. - src/openhuman/billing/ops.rs: purchase_plan / create_coinbase_charge / redeem_coupon reject empty + whitespace inputs before any HTTP call; update_card / delete_card reject empty paymentMethodId; top_up_credits rejects zero, negative, NaN, ±Infinity amounts; gateway validation fires after amount validation. - src/openhuman/team/ops.rs: build_api_path edge cases (empty list, segment ordering, space + unicode percent-encoding); normalize_id trims edges but preserves interior whitespace; every team op that normalizes an ID rejects empty/whitespace before hitting the backend; composite ops (remove_member, change_member_role, revoke_invite) check identifiers in left-to-right order so error messages are deterministic.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThis PR adds comprehensive unit tests across core and openhuman modules, covering parameter validation, registry validation, RPC routing, JSON-RPC helpers, schema types, billing operations, team operations, and RPC outcome serialization. All changes are test-only with no modifications to public APIs or exports. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Two implementation plans drafted from the life-capture spec: - Track 1 (ship pipeline): fix Ubuntu installer smoke, land in-flight PRs tinyhumansai#806/tinyhumansai#786/tinyhumansai#788/tinyhumansai#797, wire Tauri auto-updater + signed Mac/Windows builds. - Life-Capture #1 (foundation): SQLite + sqlite-vec personal_index.db, Embedder trait + HostedEmbedder (OpenAI), PII redaction, quoted-thread stripping, hybrid retrieval (vector + keyword + recency), controller schema + RPC. End-to-end test with synthetic items. No ingestion or UI yet — those are subsequent milestone plans.
Two implementation plans drafted from the life-capture spec: - Track 1 (ship pipeline): fix Ubuntu installer smoke, land in-flight PRs tinyhumansai#806/tinyhumansai#786/tinyhumansai#788/tinyhumansai#797, wire Tauri auto-updater + signed Mac/Windows builds. - Life-Capture #1 (foundation): SQLite + sqlite-vec personal_index.db, Embedder trait + HostedEmbedder (OpenAI), PII redaction, quoted-thread stripping, hybrid retrieval (vector + keyword + recency), controller schema + RPC. End-to-end test with synthetic items. No ingestion or UI yet — those are subsequent milestone plans.
Two implementation plans drafted from the life-capture spec: - Track 1 (ship pipeline): fix Ubuntu installer smoke, land in-flight PRs tinyhumansai#806/tinyhumansai#786/tinyhumansai#788/tinyhumansai#797, wire Tauri auto-updater + signed Mac/Windows builds. - Life-Capture #1 (foundation): SQLite + sqlite-vec personal_index.db, Embedder trait + HostedEmbedder (OpenAI), PII redaction, quoted-thread stripping, hybrid retrieval (vector + keyword + recency), controller schema + RPC. End-to-end test with synthetic items. No ingestion or UI yet — those are subsequent milestone plans.
Two implementation plans drafted from the life-capture spec: - Track 1 (ship pipeline): fix Ubuntu installer smoke, land in-flight PRs tinyhumansai#806/tinyhumansai#786/tinyhumansai#788/tinyhumansai#797, wire Tauri auto-updater + signed Mac/Windows builds. - Life-Capture #1 (foundation): SQLite + sqlite-vec personal_index.db, Embedder trait + HostedEmbedder (OpenAI), PII redaction, quoted-thread stripping, hybrid retrieval (vector + keyword + recency), controller schema + RPC. End-to-end test with synthetic items. No ingestion or UI yet — those are subsequent milestone plans.
Two implementation plans drafted from the life-capture spec: - Track 1 (ship pipeline): fix Ubuntu installer smoke, land in-flight PRs tinyhumansai#806/tinyhumansai#786/tinyhumansai#788/tinyhumansai#797, wire Tauri auto-updater + signed Mac/Windows builds. - Life-Capture #1 (foundation): SQLite + sqlite-vec personal_index.db, Embedder trait + HostedEmbedder (OpenAI), PII redaction, quoted-thread stripping, hybrid retrieval (vector + keyword + recency), controller schema + RPC. End-to-end test with synthetic items. No ingestion or UI yet — those are subsequent milestone plans.
Summary
Test-only hardening for the Rust core RPC layer and two domain
opsmodules. No production code changes — every added line lives under#[cfg(test)]or amod testsblock.Covers:
src/rpc/mod.rs—RpcOutcome<T>constructor, log handling, and JSON serialization shapesrc/core/mod.rs—ControllerSchema/FieldSchema/TypeSchemametadata invariantssrc/core/dispatch.rs— core dispatch routing, unknown-method behaviorsrc/core/jsonrpc.rs— helper contracts:params_to_object,parse_json_params,escape_html,type_name,is_session_expired_errorsrc/core/all.rs—validate_paramsedge cases (missing optional, extra fields, type mismatches)src/openhuman/billing/ops.rs— pre-HTTP input validation (empty/whitespace plan, payment method id, coupon code; zero/NaN/±Inf top-up amount; gateway normalization)src/openhuman/team/ops.rs—build_api_pathedge cases and registry coverageWhy it matters
Locks in the current behavior of the JSON-RPC envelope and pre-HTTP input validation so future refactors of the core registry and adapters (
core_server::dispatch,core/jsonrpc) can't silently regress input shape, error messages, or dispatch routing.Validation
Pre-HTTP billing tests are explicitly documented to only exercise argument checks that run before any HTTP call — no network, no backend, no stored session token required.
Risk
Minimal. Tests only. No runtime behavior change.
Summary by CodeRabbit
Release Notes