这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@homanp
Copy link
Collaborator

@homanp homanp commented Sep 1, 2025

Description

This pull request updates how request headers and bodies are logged in both the Node.js and Rust implementations of the proxy server. The changes improve the structure and completeness of logged data by switching header serialization to JSON and removing previous truncation of request bodies.

Logging improvements:

  • In node/src/server.js, the request body is no longer truncated to 10,000 characters before logging; the full body is now logged after redacting sensitive content.
  • In rust/src/server.rs, request headers are now serialized as a JSON object rather than a comma-separated string, making them easier to parse and use. [1] [2]
  • In rust/src/server.rs, the request body is now logged in full, rather than being truncated to 10,000 characters. [1] [2]

Checklist

  • I tested my changes
  • I reviewed my own code

@homanp homanp merged commit a04ffd9 into main Sep 1, 2025
1 check passed
@claude
Copy link

claude bot commented Sep 1, 2025

Code Review Feedback

Thank you for this pull request! I have conducted a comprehensive review of the logging improvements. Here is my analysis:

Positive Aspects

Code Quality & Best Practices:

  • Clean, focused changes that improve logging structure
  • Consistent implementation across both Node.js and Rust codebases
  • Good use of proper JSON serialization instead of manual string concatenation
  • The Rust implementation correctly uses filter_map to handle header value conversion errors gracefully

Functionality Improvements:

  • Removing 10,000 character truncation ensures complete webhook payload transmission
  • JSON serialization of headers in Rust makes them easier to parse and process programmatically
  • Both implementations maintain existing redaction functionality for security

⚠️ Areas for Consideration

Performance Concerns:

  1. Memory Usage: Logging full request/response bodies could significantly increase memory consumption for large payloads (files, images, large JSON). Consider:

    • Adding a configurable size limit (e.g., via environment variable MAX_LOG_BODY_SIZE)
    • Only logging full bodies for webhooks, not general request logging
  2. JSON Processing: The Rust implementation now creates a HashMap and serializes it for every request. This adds computational overhead vs the previous string concatenation.

Security Considerations:

  1. Sensitive Data Exposure: While redaction is applied, full body logging increases risk surface area:

    • Large payloads may contain sensitive data in unexpected formats
    • Consider adding body size warnings in logs
    • Ensure webhook endpoints are properly secured
  2. Log Storage: Full request bodies will significantly increase log volume:

    • Could impact log storage costs
    • May affect log retention policies
    • Consider log level controls for detailed logging

Potential Issues:

  1. Error Handling: The Rust implementation uses v.to_str().ok() which silently drops non-UTF8 headers. Consider logging a warning when headers are dropped.

  2. Consistency: Verify that the Node.js truncation removal is complete across all logging locations.

🔧 Recommendations

  1. Add Configuration: Consider making the full body logging configurable:

    log_full_bodies: bool,
    max_log_body_size: Option<usize>,
    
  2. Add Size Warnings: Log payload sizes for monitoring:

    "body_size_bytes": requestBody ? requestBody.length : 0,
    
  3. Performance Monitoring: Monitor the impact on memory usage and response times after deployment.

  4. Documentation: Update the README.md logging examples to reflect that full bodies are now logged.

📊 Test Coverage

  • No test files found in the repository for these logging functions
  • Consider adding unit tests for the header serialization logic
  • Integration tests for webhook functionality would be valuable

Overall Assessment

This is a well-implemented improvement that addresses the core issue of incomplete webhook payloads. The code quality is good and the changes are consistent across both implementations. The main considerations are around performance and operational impact, which can be addressed through configuration and monitoring.

Recommendation: Approve with minor suggestions - The benefits outweigh the concerns, and the suggested improvements can be addressed in follow-up work.

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.

2 participants