Skip to content

fix(logging): avoid loading raw_request/raw_response in log list queries#1934

Open
Vaibhav701161 wants to merge 2 commits intomaximhq:mainfrom
Vaibhav701161:fix/logs-raw-payload-performance
Open

fix(logging): avoid loading raw_request/raw_response in log list queries#1934
Vaibhav701161 wants to merge 2 commits intomaximhq:mainfrom
Vaibhav701161:fix/logs-raw-payload-performance

Conversation

@Vaibhav701161
Copy link

Summary

When raw request and response logging is enabled, the logs list endpoint (GET /api/logs) returns the full raw_request and raw_response fields for every log entry. These fields can be quite large for long running prompts or tool-heavy responses.

Because of this, the Logs and Dashboard pages can become very slow or appear to load indefinitely when many logs contain large raw payloads.

This change avoids loading those fields in the list query and instead fetches them only when a specific log entry is opened.


Changes

  • Updated the logs list query to omit raw_request and raw_response.
  • Added a new endpoint to fetch a single log entry with the full raw payload:
GET /api/logs/{id}
  • Updated the UI to lazily fetch the full log when opening the log detail sheet.
  • Removed SetMaxOpenConns(1) from the SQLite configuration since WAL mode already supports concurrent reads.

This keeps the logs list lightweight while still allowing the full raw request/response to be inspected when needed.


Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Plugins
  • UI (Next.js)
  • Providers/Integrations
  • Docs

How to test

Run tests:

go test ./...

Build UI:

cd ui
pnpm i || npm i
pnpm build || npm run build

Manual validation

  1. Enable Raw request and response logging for a provider.
  2. Send a prompt that generates logs with large raw payloads.
  3. Open:
Observability → Logs
Observability → Dashboard

Expected behavior:

  • Logs page loads normally
  • Dashboard loads normally
  • Opening a log entry still shows the raw request and response

Screenshots / Recordings

Logs page loading normally with raw logging enabled:

Screenshot 2026-03-05 142400

Breaking changes

  • Yes
  • No

Related issues

Closes #1764


Security considerations

No changes to authentication or access control. Raw payloads remain accessible through the existing log detail view.


Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

Signed-off-by: Vaibhav mittal <vaibhavmittal929@gmail.com>
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ea28d230-c385-4d9e-a7e8-1fa4ea3f5349

📥 Commits

Reviewing files that changed from the base of the PR and between 752cd42 and f5f339e.

📒 Files selected for processing (2)
  • ui/app/workspace/logs/sheets/logDetailsSheet.tsx
  • ui/lib/store/apis/logsApi.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • ui/lib/store/apis/logsApi.ts

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added endpoint to retrieve complete log details by ID, including raw request and response data; returns 404 if a log is not found.
    • UI now fetches and displays full log information when viewing log details, with seamless fallbacks when full data isn’t available.
    • Optimized log list responses by omitting large raw blobs to reduce payload size; full details available via the new endpoint.

Walkthrough

Adds a dedicated GET /api/logs/{id} endpoint and store/plugin methods to retrieve a single log including raw_request/raw_response; list queries now omit raw blobs to reduce payloads. Frontend fetches full log on details open and merges raw fields for display.

Changes

Cohort / File(s) Summary
Query & store
framework/logstore/rdb.go, framework/logstore/sqlite.go
Main list query now omits raw_request and raw_response to avoid large blobs; minor formatting/whitespace change in sqlite.go.
Plugin / service layer
plugins/logging/operations.go, plugins/logging/utils.go
Added GetLog(ctx, id) on LoggerPlugin and LogManager / PluginLogManager to fetch a single full log by ID.
HTTP handler / route
transports/bifrost-http/handlers/logging.go
Registered GET /api/logs/{id} and added getLogByID handler that validates id, calls logManager.GetLog, maps NotFound → 404, other errors → 500, and returns the log JSON.
Frontend API
ui/lib/store/apis/logsApi.ts
Added getLogById endpoint and exported useLazyGetLogByIdQuery hook; endpoint returns full log including raw fields.
Frontend UI
ui/app/workspace/logs/sheets/logDetailsSheet.tsx
On sheet open, lazily fetches full log and merges raw_request/raw_response from the fetched fullLog with existing entry as fallbacks for rendering and copy actions.

Sequence Diagram

sequenceDiagram
    participant User as User
    participant UI as Log Details Sheet
    participant API as Frontend API
    participant Handler as HTTP Handler
    participant Manager as Log Manager
    participant Store as Log Store

    User->>UI: Open log details (with log.id)
    UI->>API: useLazyGetLogByIdQuery(log.id)
    API->>Handler: GET /api/logs/{id}
    Handler->>Manager: logManager.GetLog(ctx, id)
    Manager->>Store: store.FindByID(id)
    Store-->>Manager: return Log (includes raw_request/raw_response)
    Manager-->>Handler: return Log
    Handler-->>API: 200 JSON response
    API-->>UI: fullLog data
    UI->>UI: merge raw fields (prefer fullLog over initial)
    UI->>User: display full log details
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hopped through logs both big and small,

Lists skip the lumps to keep pages swift and tall,
One gentle hop fetches the full tale inside,
Raw request and response no longer collide,
A tiny rabbit cheer for a lighter UI glide 🥕✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Out of Scope Changes check ❓ Inconclusive One change appears out of scope: removing SetMaxOpenConns(1) from SQLite config is not mentioned in issue #1764 and is only partially explained in the PR description. Clarify whether the SetMaxOpenConns(1) removal is necessary for the fix or should be addressed in a separate PR with its own issue.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: avoiding loading raw_request/raw_response in log list queries to improve performance.
Description check ✅ Passed The description comprehensively covers all required sections: Summary, Changes, Type of change, Affected areas, How to test, Breaking changes, Related issues, Security considerations, and Checklist.
Linked Issues check ✅ Passed The PR successfully addresses issue #1764 by implementing all required changes: omitting raw fields from list queries, adding a GET /api/logs/{id} endpoint, and implementing lazy-fetch UI logic to restore responsiveness.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ui/app/workspace/logs/sheets/logDetailsSheet.tsx`:
- Around line 79-82: The current merge uses fullLog unconditionally and can show
stale data from a previously opened entry; change the merge to only use fullLog
when it matches the current log by checking fullLog.id === log.id before falling
back to log values. Update the assignments that produce rawRequest and
rawResponse (referencing fullLog and log in logDetailsSheet.tsx) so they use
fullLog.raw_request / fullLog.raw_response only if fullLog exists and fullLog.id
=== log.id, otherwise use log.raw_request / log.raw_response.

In `@ui/lib/store/apis/logsApi.ts`:
- Around line 330-332: The getLogById query currently interpolates raw id into
the path in the query function for getLogById; update the query builder inside
getLogById to URL-encode the id (e.g., use encodeURIComponent on the id passed
to query) so reserved characters won't break routing—modify the query: (id) =>
`/logs/${encodeURIComponent(id)}` while leaving providesTags and other logic
unchanged.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 24951187-a2f0-40ed-866d-14b02b792924

📥 Commits

Reviewing files that changed from the base of the PR and between 6d95b8a and 752cd42.

📒 Files selected for processing (7)
  • framework/logstore/rdb.go
  • framework/logstore/sqlite.go
  • plugins/logging/operations.go
  • plugins/logging/utils.go
  • transports/bifrost-http/handlers/logging.go
  • ui/app/workspace/logs/sheets/logDetailsSheet.tsx
  • ui/lib/store/apis/logsApi.ts

@akshaydeo
Copy link
Contributor

❤️ for the PR @Vaibhav701161

This looks solid. Actually I had a branch fixing this - but your changes look solid. There is one valid comment by CodeRabbit - could you check that

Signed-off-by: Vaibhav mittal <vaibhavmittal929@gmail.com>
@Vaibhav701161
Copy link
Author

Thanks for the review @akshaydeo
I had addressed the CodeRabbit feedback. Let me know if anything else should be adjusted.

@Vaibhav701161 Vaibhav701161 requested a review from akshaydeo March 5, 2026 15:02
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.

[Bug]: Observability -> Log and Observability ->Dashboard UIs can't load data while there is a long running prompt

2 participants