Skip to content

Conversation

@Pratham-Mishra04
Copy link
Collaborator

Summary

Added nil checks for configStore in handler constructors to prevent potential nil pointer dereferences and improved route registration logic.

Changes

  • Added nil checks in NewPluginsHandler and NewSessionHandler to return nil when configStore is nil
  • Removed redundant nil check in isAuthEnabled method since it's now handled at construction time
  • Updated route registration in BifrostHTTPServer.RegisterRoutes to only register routes for non-nil handlers

Type of change

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

Affected areas

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

How to test

  1. Run the server with and without a configStore to verify handlers are properly initialized:
# Core/Transports
go test ./transports/bifrost-http/handlers/...
go test ./transports/bifrost-http/server/...
  1. Verify that API endpoints respond correctly when configStore is nil.

Breaking changes

  • Yes
  • No

Related issues

Fixes potential nil pointer dereference issues when configStore is not provided.

Security considerations

Prevents potential server crashes from nil pointer dereferences, which could be exploited for denial of service.

Checklist

  • I added/updated tests where appropriate
  • I verified builds succeed (Go and UI)

@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2025

🧪 Test Suite Available

This PR can be tested by a repository admin.

Run tests for PR #784

Copy link
Collaborator Author

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 7, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added status-driven plugin management when configuration storage is unavailable.
    • Introduced semantic cache and observability plugin support.
  • Bug Fixes

    • Improved error handling for session and plugin operations without configuration storage.
    • Enhanced log store initialization with fallback retry logic.
  • Tests

    • Added multi-configuration integration test suite with Docker services and health validation scripts.
  • Chores

    • Version bumped to 1.3.21.
    • Enhanced release automation workflow.

Walkthrough

Plugins and session handlers were made resilient to a nil config store: plugin endpoints now report status-driven data when no config store is present and creation/updates/deletes are disallowed; session handler constructors and auth checks guard against nil config; server now always constructs the PluginsHandler; version bumped to 1.3.21. Several GitHub workflow configs, scripts, and CI/release automation files were added or modified.

Changes

Cohort / File(s) Summary
Plugin handlers
transports/bifrost-http/handlers/plugins.go
getPlugins/getPlugin return status-driven plugin views when configStore is nil; create/update/delete return 400 when configStore is nil; when configStore exists, responses merge configStore entries with loader status.
Session handler
transports/bifrost-http/handlers/session.go
NewSessionHandler returns nil if configStore is nil; login/logout and isAuthEnabled guard against nil configStore and return 403 / is_auth_enabled:false when appropriate.
Server wiring & version
transports/bifrost-http/server/server.go, transports/version
PluginsHandler is instantiated unconditionally in server setup; route registration still checks for nil handlers; version bumped 1.3.20 → 1.3.21.
Logstore & config init
framework/logstore/sqlite.go, transports/bifrost-http/lib/config.go, framework/logstore/store.go
SQLite logstore initialization now creates missing DB file, sets foreign_keys=1, uses silent GORM logger; config path improved to retry/auto-default logs store to SQLite when missing. Minor whitespace change in store.go.
CI configs & scripts
.github/workflows/configs/... (multiple config.json files), .github/workflows/configs/docker-compose.yml, .github/workflows/scripts/get_curls.sh, .github/workflows/scripts/release-bifrost-http.sh
Added multiple workflow config JSONs for different config permutations, docker-compose for integration tests, health-check script, and a large release automation script (dependency resolution, build/test, integration-run, tagging, and GitHub release logic).
Changelog & UI types
transports/changelog.md, ui/lib/types/guardrail.ts
Added changelog entry for integration tests; removed GuardrailProvider interface from ui/lib/types/guardrail.ts.

Sequence Diagram(s)

sequenceDiagram
    participant Server
    participant PluginsHandler
    participant PluginsLoader
    participant ConfigStore
    rect rgb(223,242,225)
      Server->>PluginsHandler: NewPluginsHandler(configStore, pluginsLoader)  (now always constructed)
    end
    Server->>PluginsHandler: HTTP GET /plugins
    alt configStore == nil
      PluginsHandler->>PluginsLoader: GetPluginStatus() 
      PluginsHandler-->>Server: 200 { plugins: [name, enabled:true, config:{}, isCustom:true, status] , count }
    else configStore != nil
      PluginsHandler->>ConfigStore: ListPlugins()
      PluginsHandler->>PluginsLoader: GetPluginStatus()
      PluginsHandler-->>Server: 200 { plugins: merged(name,enabled,config,isCustom,path,status), count }
    end
Loading
sequenceDiagram
    participant Client
    participant SessionHandler
    participant ConfigStore
    Client->>SessionHandler: POST /login
    alt configStore == nil
      SessionHandler-->>Client: 403 "Authentication is not enabled"
    else
      SessionHandler->>ConfigStore: GetAuthConfig(ctx)
      SessionHandler-->>Client: 200/401 (normal auth flow)
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Inspect plugins.go merges between configStore entries and loader statuses for correctness and edge cases.
  • Verify session auth nil-guard paths and ensure no unintended permission regressions.
  • Review the large release automation script for safety (credentials, tagging, artifact publishing) and cross-platform behavior.
  • Check new CI config JSONs and docker-compose addresses/ports for conflicts.

Possibly related PRs

Suggested reviewers

  • danpiths

Poem

🐰 A nimble hop through code and test,
Guards in place so things behave best.
Plugins report with status bright,
Sessions check if auth's in sight.
Version bumped — the meadow's blessed. 🥕

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding nil checks for configStore in handlers and server initialization to prevent nil pointer dereferences.
Description check ✅ Passed The description follows the template structure with all critical sections completed: Summary, Changes, Type of change, Affected areas, How to test, Breaking changes, Security considerations, and Checklist items marked.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9078a03 and ecf240a.

📒 Files selected for processing (20)
  • .github/workflows/configs/docker-compose.yml (1 hunks)
  • .github/workflows/configs/noconfigstorenologstore/config.json (1 hunks)
  • .github/workflows/configs/witconfigstorelogstorepostgres/config.json (1 hunks)
  • .github/workflows/configs/withconfigstore/config.json (1 hunks)
  • .github/workflows/configs/withconfigstorelogsstorepostgres/config.json (1 hunks)
  • .github/workflows/configs/withconfigstorelogsstoresqlite/config.json (1 hunks)
  • .github/workflows/configs/withdynamicplugin/config.json (1 hunks)
  • .github/workflows/configs/withobservability/config.json (1 hunks)
  • .github/workflows/configs/withsemanticcache/config.json (1 hunks)
  • .github/workflows/scripts/get_curls.sh (1 hunks)
  • .github/workflows/scripts/release-bifrost-http.sh (2 hunks)
  • framework/logstore/sqlite.go (2 hunks)
  • framework/logstore/store.go (1 hunks)
  • transports/bifrost-http/handlers/plugins.go (5 hunks)
  • transports/bifrost-http/handlers/session.go (3 hunks)
  • transports/bifrost-http/lib/config.go (2 hunks)
  • transports/bifrost-http/server/server.go (2 hunks)
  • transports/changelog.md (1 hunks)
  • transports/version (1 hunks)
  • ui/lib/types/guardrail.ts (0 hunks)

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

@Pratham-Mishra04 Pratham-Mishra04 force-pushed the 11-07-fix_handle_case_when_config_store_is_nil_in_session_and_plugins_handlers branch from 48984cf to 9078a03 Compare November 7, 2025 14:52
@akshaydeo akshaydeo force-pushed the 11-07-fix_handle_case_when_config_store_is_nil_in_session_and_plugins_handlers branch from 9078a03 to 3e478a3 Compare November 7, 2025 19:45
@akshaydeo akshaydeo force-pushed the 11-07-fix_handle_case_when_config_store_is_nil_in_session_and_plugins_handlers branch from 3e478a3 to ecf240a Compare November 7, 2025 19:46
Copy link
Contributor

akshaydeo commented Nov 7, 2025

Merge activity

  • Nov 7, 7:48 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • Nov 7, 7:48 PM UTC: @akshaydeo merged this pull request with Graphite.

@akshaydeo akshaydeo merged commit 677b703 into main Nov 7, 2025
3 checks passed
@akshaydeo akshaydeo deleted the 11-07-fix_handle_case_when_config_store_is_nil_in_session_and_plugins_handlers branch November 7, 2025 19:48
akshaydeo added a commit that referenced this pull request Nov 17, 2025
## Summary

Added nil checks for configStore in handler constructors to prevent potential nil pointer dereferences and improved route registration logic.

## Changes

- Added nil checks in `NewPluginsHandler` and `NewSessionHandler` to return nil when configStore is nil
- Removed redundant nil check in `isAuthEnabled` method since it's now handled at construction time
- Updated route registration in `BifrostHTTPServer.RegisterRoutes` to only register routes for non-nil handlers

## Type of change

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

## Affected areas

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

## How to test

1. Run the server with and without a configStore to verify handlers are properly initialized:

```sh
# Core/Transports
go test ./transports/bifrost-http/handlers/...
go test ./transports/bifrost-http/server/...
```

2. Verify that API endpoints respond correctly when configStore is nil.

## Breaking changes

- [ ] Yes
- [x] No

## Related issues

Fixes potential nil pointer dereference issues when configStore is not provided.

## Security considerations

Prevents potential server crashes from nil pointer dereferences, which could be exploited for denial of service.

## Checklist

- [x] I added/updated tests where appropriate
- [x] I verified builds succeed (Go and UI)
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