Refactor caching and error handling to use Ferret v2#63
Open
Refactor caching and error handling to use Ferret v2#63
Conversation
…e error response details
Contributor
There was a problem hiding this comment.
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/v2and 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 on lines
57
to
60
| func WithCustomCDP(cdp CDPSettings) Option { | ||
| return func(opts *Options) { | ||
| opts.cdp = cdp | ||
| } |
Comment on lines
+36
to
42
| //drivers: []drivers.Driver{ | ||
| // cdp.NewDriver( | ||
| // cdp.WithAddress(opts.cdp.BaseURL()), | ||
| // ), | ||
| // http.NewDriver(), | ||
| //}, | ||
| cache: opts.cache, |
|
|
||
| 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" | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
errormessage and detailed diagnostics in a newdetailsfield, 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:
github.com/MontFerret/ferret/v2and updated related dependencies, removing old indirect dependencies and updating others for compatibility. [1] [2]Build and scripts:
versions.shscript to thescripts/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.