Skip to content

Allow hook based logs#1051

Merged
VisargD merged 2 commits into
mainfrom
feat/traces-for-plugins
May 5, 2025
Merged

Allow hook based logs#1051
VisargD merged 2 commits into
mainfrom
feat/traces-for-plugins

Conversation

@roh26it
Copy link
Copy Markdown
Collaborator

@roh26it roh26it commented Apr 21, 2025

Code Quality new feature

Title: Allow hook based logs

🔄 What Changed

  • Added a new log property to the GuardrailCheckResult interface
  • Modified the hooks manager to include this log property in the result object

🔍 Impact of the Change

  • Enables hooks to return log information that can be captured and processed by the gateway
  • Enhances observability and debugging capabilities of the hooks system

📁 Total Files Changed

  • 2 files modified (src/middlewares/hooks/index.ts, src/middlewares/hooks/types.ts)
  • 2 lines added, 0 lines removed

🧪 Test Added

N/A - No tests were added in this PR

🔒 Security Vulnerabilities

No security vulnerabilities identified in this change

Quality Recommendations

  1. Add type safety by specifying a more specific type for the log property instead of using any

  2. Consider adding validation or sanitization for the log property to prevent potential issues with large or malformed log data

  3. Add unit tests to verify the new logging functionality works as expected

@matterai-app
Copy link
Copy Markdown
Contributor

matterai-app Bot commented May 5, 2025

Code Quality new feature

Summary By MatterAI MatterAI logo

🔄 What Changed

Added support for hook-based logs by introducing a new optional log field in the GuardrailCheckResult interface and including this field in the check result object.

🔍 Impact of the Change

This change allows hooks to return log data that can be stored and processed alongside other check results, enhancing the logging capabilities of the guardrail system.

📁 Total Files Changed

2 files modified:

  • src/middlewares/hooks/index.ts: Added log field to check result object
  • src/middlewares/hooks/types.ts: Added log field to GuardrailCheckResult interface

🧪 Test Added

N/A - No tests were included in this PR.

🔒Security Vulnerabilities

No security vulnerabilities detected.

Type of Change

  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Refactoring (no functional changes)

How Has This Been Tested?

  • Unit Tests
  • Integration Tests
  • Manual Testing

Screenshots (if applicable)

N/A

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

Related Issues

N/A

Sequence Diagram

sequenceDiagram
    participant Client
    participant HooksManager
    participant GuardrailCheck
    
    Client->>HooksManager: Execute guardrail check
    HooksManager->>GuardrailCheck: Process check
    GuardrailCheck-->>HooksManager: Return result with log data
    Note over GuardrailCheck,HooksManager: New log field added to result
    HooksManager->>HooksManager: Store check result
    Note over HooksManager: Include log: result.log || null
    HooksManager-->>Client: Return guardrail result
Loading

@VisargD VisargD merged commit 4d91fa1 into main May 5, 2025
1 check passed
@VisargD VisargD deleted the feat/traces-for-plugins branch May 5, 2025 04:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants