Skip to content

Refactor caching and error handling to use Ferret v2#63

Open
ziflex wants to merge 1 commit intomasterfrom
feat/ferret-v2
Open

Refactor caching and error handling to use Ferret v2#63
ziflex wants to merge 1 commit intomasterfrom
feat/ferret-v2

Conversation

@ziflex
Copy link
Copy Markdown
Member

@ziflex ziflex commented May 2, 2026

This pull request introduces several important improvements to error handling, dependency management, and the codebase structure, primarily to support Ferret v2 and provide more informative error responses. The most significant changes are grouped below.

Error handling and API improvements:

  • Enhanced error responses: The API now returns structured error objects with both an error message and detailed diagnostics in a new details field, improving troubleshooting for clients. This applies to both the HTTP API and OpenAPI schema, and is covered by new tests. [1] [2] [3] [4] [5] [6] [7]

Upgrade to Ferret v2 and refactoring:

  • Upgraded to github.com/MontFerret/ferret/v2 and updated related dependencies, removing old indirect dependencies and updating others for compatibility. [1] [2]
  • Refactored worker code to use the new Ferret v2 engine and plan/session APIs, replacing the old compiler/program model. This includes changes to caching, engine options, and query execution. [1] [2] [3] [4] [5] [6] [7] [8] [9]

Build and scripts:

  • Moved the versions.sh script to the scripts/ directory and updated the Makefile to reference the new location. The script was also rewritten for improved version extraction. [1] [2] [3]

These changes modernize the project to use Ferret v2, provide richer error information for clients, and improve maintainability.

Copilot AI review requested due to automatic review settings May 2, 2026 15:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR upgrades the worker to Ferret v2, refactors query compilation/execution around the new engine/plan/session APIs, and updates the HTTP error shape to include diagnostic details for easier client troubleshooting.

Changes:

  • Upgrade Ferret dependency to github.com/MontFerret/ferret/v2 and refactor worker compilation/execution + cache to store compiled plans.
  • Return structured API errors with error + details (formatted Ferret diagnostics where available), plus OpenAPI/README updates.
  • Move/rewrite the version script under scripts/ and adjust Makefile references.

Reviewed changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
versions.sh Removes old root-level version script (moved to scripts/).
scripts/versions.sh New version extraction script (supports Ferret v2 module path).
Makefile Updates VERSION/FERRET_VERSION commands to use scripts/versions.sh.
go.mod Switches to Ferret v2 and updates dependency set.
go.sum Reflects updated module checksums after dependency changes.
pkg/worker/worker.go Refactors to Ferret v2 engine/plan/session; updates caching type and result handling.
pkg/worker/options.go Reworks options to Ferret v2 engine options; cache now stores plans.
pkg/worker/models.go Adds ContentType to result model.
internal/storage/cache.go Updates in-memory cache to store *ferret.Plan.
internal/controllers/common.go Adds details field to HTTP error responses and formats diagnostics when possible.
internal/controllers/worker.go Uses new structured error responses on request/exec failures.
internal/controllers/common_test.go Adds unit tests for newHTTPError formatting behavior.
internal/controllers/worker_test.go Adds integration-style test ensuring diagnostic details are returned from the endpoint.
reference/ferret-worker.yaml Updates Error schema to include required details.
README.md Documents new structured error response format.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/worker/options.go
Comment on lines 57 to 60
func WithCustomCDP(cdp CDPSettings) Option {
return func(opts *Options) {
opts.cdp = cdp
}
Comment thread pkg/worker/worker.go
Comment on lines +36 to 42
//drivers: []drivers.Driver{
// cdp.NewDriver(
// cdp.WithAddress(opts.cdp.BaseURL()),
// ),
// http.NewDriver(),
//},
cache: opts.cache,
Comment thread pkg/worker/worker.go

return Result{
Raw: r,
ContentType: out.ContentType,
Comment on lines +1 to +12
package controllers

import (
stderrors "errors"
"strings"
"testing"

pkgerrors "github.com/pkg/errors"

"github.com/MontFerret/ferret/v2/pkg/diagnostics"
"github.com/MontFerret/ferret/v2/pkg/source"
)
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