Skip to content

server logs config - #4653

Merged
akshaydeo merged 1 commit into
devfrom
06-24-server_logs_config
Jun 24, 2026
Merged

akshaydeo merged 1 commit into
devfrom
06-24-server_logs_config

Conversation

@akshaydeo

@akshaydeo akshaydeo commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a new dump_errors_in_console_logs client configuration option that, when enabled, writes full HTTP error response bodies to the server console logs. This is intended to aid debugging without requiring a server restart or log level change.

Changes

  • Added DumpErrorsInConsoleLogs field to ClientConfig, TableClientConfig, and the RDB read/write paths.
  • Added a database migration (add_dump_errors_in_console_logs_column) to introduce the column with a default of false.
  • Refactored CorsMiddleware from a plain function into a CorsMiddleware struct backed by an atomic.Pointer[lib.Config], allowing the config (including the new flag) to be swapped at runtime without restarting the server and without data races on in-flight requests.
  • When DumpErrorsInConsoleLogs is true, the CORS/logging middleware appends the response body as http.error to the structured log entry for any response with a status code ≥ 400.
  • Wired DumpErrorsInConsoleLogs into the config update handler so changes take effect immediately via the atomic config pointer.
  • Added the field to the config hash, using a non-default-only hashing strategy to avoid hash churn on upgrade for existing deployments.
  • Exposed the setting in the Helm chart (values.yaml, values.schema.json, _helpers.tpl, README.md), the transport config schema (config.schema.json), and the UI settings view with a toggle and description.

Type of change

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

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

# Core/Transports
go test ./framework/configstore/...
go test ./transports/bifrost-http/...

# UI
cd ui
pnpm i
pnpm build
  1. Set dump_errors_in_console_logs: true in the client config (via UI toggle or config file).
  2. Issue a request that produces a 4xx or 5xx response.
  3. Confirm the server console log for that request includes an http.error field containing the response body.
  4. Toggle the setting off and confirm the field no longer appears in logs without restarting the server.

New config field:

Field Type Default Description
dump_errors_in_console_logs boolean false When true, full error response bodies are written to server console logs. Useful for debugging; may be noisy in production.

Breaking changes

  • No

The CorsMiddleware function signature changed to a struct-based API (NewCorsMiddleware + .Middleware()). Any code outside this repository calling CorsMiddleware(config) directly will need to be updated to NewCorsMiddleware(config).Middleware().

Security considerations

Error response bodies logged to the console may contain sensitive information (e.g., upstream provider error messages, request details). This feature is disabled by default and should be used with care in production environments.

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

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 6af9c8d3-1db5-42c6-b137-0074067cd55f

📥 Commits

Reviewing files that changed from the base of the PR and between d852f25 and 0371f7b.

📒 Files selected for processing (20)
  • framework/configstore/clientconfig.go
  • framework/configstore/migrations.go
  • framework/configstore/rdb.go
  • framework/configstore/tables/clientconfig.go
  • helm-charts/bifrost/README.md
  • helm-charts/bifrost/templates/_helpers.tpl
  • helm-charts/bifrost/values.schema.json
  • helm-charts/bifrost/values.yaml
  • tests/cmd/e2eseed/go.mod
  • tests/cmd/seed/go.mod
  • tests/cmd/seedvks/go.mod
  • transports/bifrost-http/handlers/config.go
  • transports/bifrost-http/handlers/middlewares.go
  • transports/bifrost-http/handlers/middlewares_test.go
  • transports/bifrost-http/handlers/realtime_turn_pipeline.go
  • transports/bifrost-http/handlers/wsrealtime.go
  • transports/bifrost-http/server/server.go
  • transports/config.schema.json
  • ui/app/workspace/config/views/clientSettingsView.tsx
  • ui/lib/types/config.ts
✅ Files skipped from review due to trivial changes (6)
  • tests/cmd/seedvks/go.mod
  • helm-charts/bifrost/README.md
  • ui/app/workspace/config/views/clientSettingsView.tsx
  • transports/config.schema.json
  • tests/cmd/e2eseed/go.mod
  • helm-charts/bifrost/templates/_helpers.tpl
🚧 Files skipped from review as they are similar to previous changes (12)
  • transports/bifrost-http/handlers/config.go
  • framework/configstore/clientconfig.go
  • helm-charts/bifrost/values.yaml
  • tests/cmd/seed/go.mod
  • helm-charts/bifrost/values.schema.json
  • framework/configstore/rdb.go
  • framework/configstore/tables/clientconfig.go
  • transports/bifrost-http/handlers/middlewares_test.go
  • ui/lib/types/config.ts
  • framework/configstore/migrations.go
  • transports/bifrost-http/server/server.go
  • transports/bifrost-http/handlers/middlewares.go

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added Dump Errors in Console Logs client setting (default false), available in the UI, persisted in configuration, and configurable via Helm chart values.
  • Bug Fixes

    • Improved change detection and config reconciliation so the setting correctly round-trips between storage and API responses.
    • CORS settings now refresh after client config reloads without requiring a restart.
  • Documentation

    • Updated the Helm chart README and values schema to document the new setting.

Walkthrough

A new dump_errors_in_console_logs client setting is added through config storage, HTTP propagation, hot-reloadable CORS handling, UI controls, and Helm chart wiring, with matching schema, migration, and test dependency updates.

Changes

Dump errors config propagation

Layer / File(s) Summary
Data model and migration
framework/configstore/tables/clientconfig.go, framework/configstore/clientconfig.go, framework/configstore/migrations.go
Adds DumpErrorsInConsoleLogs to the stored and API client config shapes, includes it in the config hash, and adds the migration that creates and drops the database column.
Configstore read/write round-trip
framework/configstore/rdb.go
Persists DumpErrorsInConsoleLogs to the DB row and reads it back into ClientConfig.
HTTP config propagation and CORS reload
transports/bifrost-http/handlers/config.go, transports/bifrost-http/handlers/middlewares.go, transports/bifrost-http/server/server.go, transports/config.schema.json
Copies the incoming flag into updated config, changes CORS middleware to a stateful snapshot-based type, reloads it from server config updates, and adds the transport schema property.
Realtime trace context inheritance
transports/bifrost-http/handlers/wsrealtime.go, transports/bifrost-http/handlers/realtime_turn_pipeline.go
Stops inheriting the upgrade request trace ID into realtime turns and skips nil context values while copying turn context data.
CORS middleware test updates
transports/bifrost-http/handlers/middlewares_test.go
Updates all CORS tests to use NewCorsMiddleware(config).Middleware().
UI type definition and settings toggle
ui/lib/types/config.ts, ui/app/workspace/config/views/clientSettingsView.tsx
Adds the field to core config types and renders a new settings switch with unsaved-change tracking.
Helm values, schema, template, and docs
helm-charts/bifrost/values.yaml, helm-charts/bifrost/values.schema.json, helm-charts/bifrost/templates/_helpers.tpl, helm-charts/bifrost/README.md
Adds bifrost.client.dumpErrorsInConsoleLogs to values, schema, generated config, and documentation.
Dependency version bumps
tests/cmd/*/go.mod
Bumps github.com/maximhq/bifrost/core to v1.5.22 in three test module files.

Sequence Diagram(s)

sequenceDiagram
  participant Client as HTTP Client
  participant updateConfig as updateConfig
  participant BifrostHTTPServer as BifrostHTTPServer
  participant CorsMiddleware as CorsMiddleware
  participant Fasthttp as fasthttp handler chain

  Client->>updateConfig: send client config with dump_errors_in_console_logs
  updateConfig->>BifrostHTTPServer: update Config
  BifrostHTTPServer->>CorsMiddleware: UpdateConfig(s.Config)
  Fasthttp->>CorsMiddleware: Middleware()
  CorsMiddleware-->>Fasthttp: per-request cfg snapshot
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested reviewers

  • danpiths

Poem

🐇 A toggle hopped in, bright and new,
Errors can echo straight through.
CORS snaps fresh on the fly,
Configs update without a sigh.
The bunny twitches its nose with glee,
“Hop, log, reload—just let it be!”

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is too generic and doesn't identify the actual config or logging change. Rename it to something specific like "Add dump_errors_in_console_logs client setting".
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description matches the template well and includes summary, changes, testing, breaking changes, and security notes.
Docstring Coverage ✅ Passed Docstring coverage is 86.96% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 06-24-server_logs_config

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


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

@akshaydeo
akshaydeo marked this pull request as ready for review June 24, 2026 08:07
@akshaydeo
akshaydeo requested a review from a team as a code owner June 24, 2026 08:07

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

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 current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@transports/bifrost-http/handlers/middlewares.go`:
- Around line 74-96: The CORS middleware still shares mutable `*lib.Config`, so
atomic pointer swaps do not prevent races on nested fields like
`ClientConfig.DumpErrorsInConsoleLogs`, `AllowedOrigins`, and `AllowedHeaders`.
Refactor `CorsMiddleware`, `NewCorsMiddleware`, `UpdateConfig`, and
`Middleware()` to store and read a small immutable snapshot struct instead of
`*lib.Config`, and clone the slices when building or updating the snapshot.
Ensure `Middleware()` only reads the snapshot fields (`dumpErrorsInConsoleLogs`,
`allowedOrigins`, `allowedHeaders`) so each request sees a consistent config.

In `@ui/app/workspace/config/views/clientSettingsView.tsx`:
- Around line 350-355: The new toggle in clientSettingsView’s Switch is missing
a stable Playwright hook. Add a data-testid to this control using the existing
3-part convention and match sibling naming patterns in clientSettingsView, e.g.
a client-settings-dump-errors-switch identifier on the Switch tied to
dump_errors_in_console_logs.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 47690e10-7198-487a-8926-1367863acf06

📥 Commits

Reviewing files that changed from the base of the PR and between fdd4d19 and 35a9370.

📒 Files selected for processing (18)
  • framework/configstore/clientconfig.go
  • framework/configstore/migrations.go
  • framework/configstore/rdb.go
  • framework/configstore/tables/clientconfig.go
  • helm-charts/bifrost/README.md
  • helm-charts/bifrost/templates/_helpers.tpl
  • helm-charts/bifrost/values.schema.json
  • helm-charts/bifrost/values.yaml
  • tests/cmd/e2eseed/go.mod
  • tests/cmd/seed/go.mod
  • tests/cmd/seedvks/go.mod
  • transports/bifrost-http/handlers/config.go
  • transports/bifrost-http/handlers/middlewares.go
  • transports/bifrost-http/handlers/middlewares_test.go
  • transports/bifrost-http/server/server.go
  • transports/config.schema.json
  • ui/app/workspace/config/views/clientSettingsView.tsx
  • ui/lib/types/config.ts

Comment thread transports/bifrost-http/handlers/middlewares.go
Comment thread ui/app/workspace/config/views/clientSettingsView.tsx
@greptile-apps

greptile-apps Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

Safe to merge; the feature is disabled by default and the hot-reload wiring is correct across all layers.

The atomic config swap, slice cloning, and explicit UpdateConfig call in the reload path are all correctly implemented. The new DB migration is a simple column add with a rollback path. The only gaps are the absence of a body-size cap on the logged error field and no unit test for the new logging behavior — both are quality concerns on a feature that is off by default.

middlewares.go (body truncation) and middlewares_test.go (missing coverage for the new logging path).

Important Files Changed

Filename Overview
transports/bifrost-http/handlers/middlewares.go Refactors CorsMiddleware from a plain function to an atomic-pointer-backed struct; adds dumpErrorsInConsoleLogs body-logging to the deferred request log. The atomic snapshot pattern with cloned slices is correctly implemented; the only hardening gap is that large error bodies have no size cap before they are written as the http.error log field.
framework/configstore/migrations.go Adds migrationAddDumpErrorsInConsoleLogsColumn using the existing addColumnIfNotExists helper with a rollback via dropColumnIfExists. Simple column addition with DEFAULT false; no index creation, no lock risk.
transports/bifrost-http/server/server.go Adds CORSMiddleware field to BifrostHTTPServer, initializes it in Bootstrap before PrepareCommonMiddlewares, wires it into the server handler chain, and calls UpdateConfig inside ReloadClientConfigFromConfigStore — explicit and race-safe hot-reload propagation.
transports/bifrost-http/handlers/middlewares_test.go All existing CORS tests migrated to NewCorsMiddleware(config).Middleware(); no new tests added for the dumpErrorsInConsoleLogs body-logging behavior.
transports/bifrost-http/handlers/config.go DumpErrorsInConsoleLogs is unconditionally propagated from the update payload to updatedConfig, consistent with DisableContentLogging / DisableDBPingsInHealth; comment correctly explains that restart is not needed.
transports/bifrost-http/handlers/realtime_turn_pipeline.go Fixes a bug where realtime turns inherited the session-level BifrostContextKeyTraceID, causing their log entries to be stranded under a dead trace. Now skips that key when copying base context values.
transports/bifrost-http/handlers/wsrealtime.go Removes BifrostContextKeyTraceID from realtimeMiddlewareKeys with a comment explaining why; each realtime turn mints its own trace in RunRealtimeTurnPreHooks instead.
ui/app/workspace/config/views/clientSettingsView.tsx Adds the DumpErrorsInConsoleLogs toggle to the client settings view with hasUnsavedChanges tracking, data-testid attribute, and access guard; aligns with existing toggle conventions.
framework/configstore/clientconfig.go Adds DumpErrorsInConsoleLogs field; the config hash contribution uses a non-default-only strategy (only writes the hash token when true) to avoid hash churn on upgrade for existing deployments.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant Client
    participant SecurityHeaders
    participant CORSMiddleware
    participant Downstream
    participant Logger

    Note over CORSMiddleware: atomic.Pointer[corsMiddlewareConfig]

    Client->>SecurityHeaders: HTTP request
    SecurityHeaders->>CORSMiddleware: forward

    CORSMiddleware->>CORSMiddleware: "cfg = config.Load() (atomic snapshot)"
    
    alt "cfg == nil"
        CORSMiddleware-->>Client: 500 Internal Server Error
    else cfg valid
        CORSMiddleware->>CORSMiddleware: set up deferred log (captures cfg)
        CORSMiddleware->>CORSMiddleware: check CORS headers using cfg.allowedOrigins / cfg.allowedHeaders
        
        alt OPTIONS preflight
            CORSMiddleware-->>Client: 200/403 (return early, defer fires)
        else normal request
            CORSMiddleware->>Downstream: next(ctx)
            Downstream-->>CORSMiddleware: response written
        end

        CORSMiddleware->>Logger: deferred log: status, duration, method, path
        
        alt "cfg.dumpErrorsInConsoleLogs && status >= 400 && !IsBodyStream()"
            CORSMiddleware->>Logger: "append http.error = string(body)"
        end
    end

    Note over CORSMiddleware: Hot reload path
    participant ConfigHandler
    ConfigHandler->>ConfigHandler: updateConfig() sets DumpErrorsInConsoleLogs
    ConfigHandler->>ConfigHandler: ReloadClientConfigFromConfigStore()
    ConfigHandler->>CORSMiddleware: UpdateConfig(s.Config)
    CORSMiddleware->>CORSMiddleware: config.Store(newCorsMiddlewareConfig(config))
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant Client
    participant SecurityHeaders
    participant CORSMiddleware
    participant Downstream
    participant Logger

    Note over CORSMiddleware: atomic.Pointer[corsMiddlewareConfig]

    Client->>SecurityHeaders: HTTP request
    SecurityHeaders->>CORSMiddleware: forward

    CORSMiddleware->>CORSMiddleware: "cfg = config.Load() (atomic snapshot)"
    
    alt "cfg == nil"
        CORSMiddleware-->>Client: 500 Internal Server Error
    else cfg valid
        CORSMiddleware->>CORSMiddleware: set up deferred log (captures cfg)
        CORSMiddleware->>CORSMiddleware: check CORS headers using cfg.allowedOrigins / cfg.allowedHeaders
        
        alt OPTIONS preflight
            CORSMiddleware-->>Client: 200/403 (return early, defer fires)
        else normal request
            CORSMiddleware->>Downstream: next(ctx)
            Downstream-->>CORSMiddleware: response written
        end

        CORSMiddleware->>Logger: deferred log: status, duration, method, path
        
        alt "cfg.dumpErrorsInConsoleLogs && status >= 400 && !IsBodyStream()"
            CORSMiddleware->>Logger: "append http.error = string(body)"
        end
    end

    Note over CORSMiddleware: Hot reload path
    participant ConfigHandler
    ConfigHandler->>ConfigHandler: updateConfig() sets DumpErrorsInConsoleLogs
    ConfigHandler->>ConfigHandler: ReloadClientConfigFromConfigStore()
    ConfigHandler->>CORSMiddleware: UpdateConfig(s.Config)
    CORSMiddleware->>CORSMiddleware: config.Store(newCorsMiddlewareConfig(config))
Loading

Reviews (2): Last reviewed commit: "server logs config" | Re-trigger Greptile

Comment thread transports/bifrost-http/handlers/middlewares.go Outdated
@akshaydeo
akshaydeo force-pushed the 06-24-server_logs_config branch from 35a9370 to d852f25 Compare June 24, 2026 08:20
@akshaydeo
akshaydeo force-pushed the 06-24-server_logs_config branch from d852f25 to 0371f7b Compare June 24, 2026 08:23
@coderabbitai
coderabbitai Bot requested a review from danpiths June 24, 2026 08:25

akshaydeo commented Jun 24, 2026

Copy link
Copy Markdown
Contributor Author

Merge activity

  • Jun 24, 8:30 AM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Jun 24, 8:30 AM UTC: @akshaydeo merged this pull request with Graphite.

@akshaydeo
akshaydeo merged commit f15203a into dev Jun 24, 2026
13 of 16 checks passed
@akshaydeo
akshaydeo deleted the 06-24-server_logs_config branch June 24, 2026 08:30
akshaydeo added a commit that referenced this pull request Jun 24, 2026
## Summary

Adds a new `dump_errors_in_console_logs` client configuration option that, when enabled, writes full HTTP error response bodies to the server console logs. This is intended to aid debugging without requiring a server restart or log level change.

## Changes

- Added `DumpErrorsInConsoleLogs` field to `ClientConfig`, `TableClientConfig`, and the RDB read/write paths.
- Added a database migration (`add_dump_errors_in_console_logs_column`) to introduce the column with a default of `false`.
- Refactored `CorsMiddleware` from a plain function into a `CorsMiddleware` struct backed by an `atomic.Pointer[lib.Config]`, allowing the config (including the new flag) to be swapped at runtime without restarting the server and without data races on in-flight requests.
- When `DumpErrorsInConsoleLogs` is `true`, the CORS/logging middleware appends the response body as `http.error` to the structured log entry for any response with a status code ≥ 400.
- Wired `DumpErrorsInConsoleLogs` into the config update handler so changes take effect immediately via the atomic config pointer.
- Added the field to the config hash, using a non-default-only hashing strategy to avoid hash churn on upgrade for existing deployments.
- Exposed the setting in the Helm chart (`values.yaml`, `values.schema.json`, `_helpers.tpl`, `README.md`), the transport config schema (`config.schema.json`), and the UI settings view with a toggle and description.

## Type of change

- [ ] Bug fix
- [x] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [x] Core (Go)
- [x] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [ ] Docs

## How to test

```sh
# Core/Transports
go test ./framework/configstore/...
go test ./transports/bifrost-http/...

# UI
cd ui
pnpm i
pnpm build
```

1. Set `dump_errors_in_console_logs: true` in the client config (via UI toggle or config file).
2. Issue a request that produces a 4xx or 5xx response.
3. Confirm the server console log for that request includes an `http.error` field containing the response body.
4. Toggle the setting off and confirm the field no longer appears in logs without restarting the server.

**New config field:**

| Field | Type | Default | Description |
|---|---|---|---|
| `dump_errors_in_console_logs` | `boolean` | `false` | When `true`, full error response bodies are written to server console logs. Useful for debugging; may be noisy in production. |

## Breaking changes

- [x] No

The `CorsMiddleware` function signature changed to a struct-based API (`NewCorsMiddleware` + `.Middleware()`). Any code outside this repository calling `CorsMiddleware(config)` directly will need to be updated to `NewCorsMiddleware(config).Middleware()`.

## Security considerations

Error response bodies logged to the console may contain sensitive information (e.g., upstream provider error messages, request details). This feature is disabled by default and should be used with care in production environments.

## 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
akhsaul pushed a commit to akhsaul/bifrost that referenced this pull request Aug 27, 2026
## Summary

Adds a new `dump_errors_in_console_logs` client configuration option that, when enabled, writes full HTTP error response bodies to the server console logs. This is intended to aid debugging without requiring a server restart or log level change.

## Changes

- Added `DumpErrorsInConsoleLogs` field to `ClientConfig`, `TableClientConfig`, and the RDB read/write paths.
- Added a database migration (`add_dump_errors_in_console_logs_column`) to introduce the column with a default of `false`.
- Refactored `CorsMiddleware` from a plain function into a `CorsMiddleware` struct backed by an `atomic.Pointer[lib.Config]`, allowing the config (including the new flag) to be swapped at runtime without restarting the server and without data races on in-flight requests.
- When `DumpErrorsInConsoleLogs` is `true`, the CORS/logging middleware appends the response body as `http.error` to the structured log entry for any response with a status code ≥ 400.
- Wired `DumpErrorsInConsoleLogs` into the config update handler so changes take effect immediately via the atomic config pointer.
- Added the field to the config hash, using a non-default-only hashing strategy to avoid hash churn on upgrade for existing deployments.
- Exposed the setting in the Helm chart (`values.yaml`, `values.schema.json`, `_helpers.tpl`, `README.md`), the transport config schema (`config.schema.json`), and the UI settings view with a toggle and description.

## Type of change

- [ ] Bug fix
- [x] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [x] Core (Go)
- [x] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [ ] Docs

## How to test

```sh
# Core/Transports
go test ./framework/configstore/...
go test ./transports/bifrost-http/...

# UI
cd ui
pnpm i
pnpm build
```

1. Set `dump_errors_in_console_logs: true` in the client config (via UI toggle or config file).
2. Issue a request that produces a 4xx or 5xx response.
3. Confirm the server console log for that request includes an `http.error` field containing the response body.
4. Toggle the setting off and confirm the field no longer appears in logs without restarting the server.

**New config field:**

| Field | Type | Default | Description |
|---|---|---|---|
| `dump_errors_in_console_logs` | `boolean` | `false` | When `true`, full error response bodies are written to server console logs. Useful for debugging; may be noisy in production. |

## Breaking changes

- [x] No

The `CorsMiddleware` function signature changed to a struct-based API (`NewCorsMiddleware` + `.Middleware()`). Any code outside this repository calling `CorsMiddleware(config)` directly will need to be updated to `NewCorsMiddleware(config).Middleware()`.

## Security considerations

Error response bodies logged to the console may contain sensitive information (e.g., upstream provider error messages, request details). This feature is disabled by default and should be used with care in production environments.

## 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
occcat pushed a commit to occcat/bifrost that referenced this pull request Sep 2, 2026
## Summary

Adds a new `dump_errors_in_console_logs` client configuration option that, when enabled, writes full HTTP error response bodies to the server console logs. This is intended to aid debugging without requiring a server restart or log level change.

## Changes

- Added `DumpErrorsInConsoleLogs` field to `ClientConfig`, `TableClientConfig`, and the RDB read/write paths.
- Added a database migration (`add_dump_errors_in_console_logs_column`) to introduce the column with a default of `false`.
- Refactored `CorsMiddleware` from a plain function into a `CorsMiddleware` struct backed by an `atomic.Pointer[lib.Config]`, allowing the config (including the new flag) to be swapped at runtime without restarting the server and without data races on in-flight requests.
- When `DumpErrorsInConsoleLogs` is `true`, the CORS/logging middleware appends the response body as `http.error` to the structured log entry for any response with a status code ≥ 400.
- Wired `DumpErrorsInConsoleLogs` into the config update handler so changes take effect immediately via the atomic config pointer.
- Added the field to the config hash, using a non-default-only hashing strategy to avoid hash churn on upgrade for existing deployments.
- Exposed the setting in the Helm chart (`values.yaml`, `values.schema.json`, `_helpers.tpl`, `README.md`), the transport config schema (`config.schema.json`), and the UI settings view with a toggle and description.

## Type of change

- [ ] Bug fix
- [x] Feature
- [ ] Refactor
- [ ] Documentation
- [ ] Chore/CI

## Affected areas

- [x] Core (Go)
- [x] Transports (HTTP)
- [ ] Providers/Integrations
- [ ] Plugins
- [x] UI (React)
- [ ] Docs

## How to test

```sh
# Core/Transports
go test ./framework/configstore/...
go test ./transports/bifrost-http/...

# UI
cd ui
pnpm i
pnpm build
```

1. Set `dump_errors_in_console_logs: true` in the client config (via UI toggle or config file).
2. Issue a request that produces a 4xx or 5xx response.
3. Confirm the server console log for that request includes an `http.error` field containing the response body.
4. Toggle the setting off and confirm the field no longer appears in logs without restarting the server.

**New config field:**

| Field | Type | Default | Description |
|---|---|---|---|
| `dump_errors_in_console_logs` | `boolean` | `false` | When `true`, full error response bodies are written to server console logs. Useful for debugging; may be noisy in production. |

## Breaking changes

- [x] No

The `CorsMiddleware` function signature changed to a struct-based API (`NewCorsMiddleware` + `.Middleware()`). Any code outside this repository calling `CorsMiddleware(config)` directly will need to be updated to `NewCorsMiddleware(config).Middleware()`.

## Security considerations

Error response bodies logged to the console may contain sensitive information (e.g., upstream provider error messages, request details). This feature is disabled by default and should be used with care in production environments.

## 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
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