fix: handle plain-text trust evaluation requests#1
fix: handle plain-text trust evaluation requests#1lawyered0 wants to merge 1 commit intoelizaos-plugins:1.xfrom
Conversation
WalkthroughThe pull request adds support for wrapped trust-engine services through enhanced request parsing and service retrieval logic. A new test case validates the wrapper pattern, and the handler now includes stronger validation for service availability before attempting to evaluate trust. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Tip Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord. 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 |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/actions/__tests__/evaluateTrust.test.ts (2)
195-203:⚠️ Potential issue | 🟠 MajorTest assertion will fail:
erroris a string, nottrue.The handler (line 142) returns
error: error instanceof Error ? error.message : 'Unknown error', which evaluates to the string'Database error'here. The assertion.toBe(true)will not match.Proposed fix
- expect((result as any).error).toBe(true); + expect((result as any).error).toBe('Database error');
205-214:⚠️ Potential issue | 🟠 MajorSame mismatch: handler returns an error string, not a boolean.
The handler (line 66) returns
error: 'Entity name resolution not implemented', but the test asserts.toBe(true).Proposed fix
- expect((result as any).error).toBe(true); + expect((result as any).error).toBe('Entity name resolution not implemented');
🧹 Nitpick comments (1)
src/actions/evaluateTrust.ts (1)
40-43:validatedoesn't mirror the handler's unwrap + capability check.
validatereturns!!trustEngine(truthy check on the raw service), while the handler additionally unwraps.trustEngineand verifiestypeof evaluateTrust === 'function'. If a wrapper object is registered that doesn't contain a validtrustEngine,validatewill pass but the handler will throw.Consider aligning the two so
validaterejects early:Suggested alignment
validate: async (runtime: IAgentRuntime, _message: Memory) => { - const trustEngine = runtime.getService('trust-engine'); - return !!trustEngine; + const trustService = runtime.getService('trust-engine') as any; + const trustEngine = trustService?.trustEngine ?? trustService; + return !!trustEngine && typeof trustEngine.evaluateTrust === 'function'; },
Summary
Testing
Summary by CodeRabbit
Bug Fixes
Tests