feat(pull): delegate schema pull to the data plane engine capability - #1022
Draft
aparajon wants to merge 1 commit into
Draft
feat(pull): delegate schema pull to the data plane engine capability#1022aparajon wants to merge 1 commit into
aparajon wants to merge 1 commit into
Conversation
Pull support becomes the data plane's answer instead of a control-plane type gate. LocalClient keeps the built-in MySQL/Vitess pull paths and delegates any other database type to the configured engine's new SchemaPuller capability, failing closed with ErrPullSchemaUnsupportedType when the engine does not provide it. The control plane dispatches the pull unconditionally and converts the data plane's unsupported reply (the typed sentinel locally, codes.Unimplemented from a remote deployment) into the same 501 response as before. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR shifts pull schema support determination from the control plane’s database-type gate to the data plane’s engine capabilities, so the control plane always dispatches pull and derives a 501 only from an “unsupported” response.
Changes:
- Adds a
SchemaPullerengine capability and updatesLocalClient.PullSchemato delegate non-MySQL/Vitess pulls to the configured engine (failing closed when unsupported). - Removes the control-plane type gate in
ExecutePullSchemaand converts data-plane “unsupported” signals (local sentinel or remotecodes.Unimplemented) into the existing 501. - Adds/updates tests to cover delegation, unsupported handling, and type-mismatch precedence.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/tern/local_client.go | Delegates non-MySQL/Vitess pulls to an engine capability via a new helper. |
| pkg/tern/local_client_test.go | Adds tests for delegation, unsupported capability behavior, and error cases. |
| pkg/tern/client.go | Introduces the SchemaPuller capability interface. |
| pkg/api/plan_handlers.go | Removes type gate and derives 501 from data-plane “unsupported” outcomes. |
| pkg/api/handlers_test.go | Updates tests to validate unsupported conversion behavior for local vs remote clients. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+3745
to
+3749
| _, err := client.PullSchema(t.Context(), &ternv1.PullSchemaRequest{Database: "orders"}) | ||
|
|
||
| require.Error(t, err) | ||
| assert.Contains(t, err.Error(), "nil response") | ||
| } |
Comment on lines
62
to
64
| func (e *unsupportedPullSchemaError) Error() string { | ||
| return fmt.Sprintf("pull schema supports %s and %s databases; got %s", storage.DatabaseTypeMySQL, storage.DatabaseTypeVitess, e.DatabaseType) | ||
| } |
Comment on lines
+649
to
+651
| if resp == nil { | ||
| return nil, fmt.Errorf("engine pull schema for database %s type %s returned a nil response", c.config.Database, c.config.Type) | ||
| } |
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.
Summary
Pull support becomes the data plane's answer instead of a control-plane type gate. Whether a database type supports
pulldepends on which engine backs the deployment — something only the data plane knows — so the control plane now dispatches the pull unconditionally and derives the 501 from the reply.pkg/tern: newSchemaPullercapability interface.LocalClient.PullSchemakeeps the built-in MySQL/Vitess paths and delegates any other database type to the registered engine's capability — failing closed withErrPullSchemaUnsupportedTypewhen the engine doesn't provide it, on a nil engine response, and wrapping engine errors with database/type context. The request-type mismatch check now runs before dispatch.pkg/api: theExecutePullSchematype gate is deleted. A named predicate converts the data plane's "unsupported" reply — the typed sentinel locally,codes.Unimplementedfrom a remote deployment only — into the existing 501 error. Other pull failures pass through untouched, and the raw error is still logged with full routing detail before conversion.No behavior change for mysql/vitess/postgres. Types without an engine capability move from a control-plane 501 to a data-plane 501 with the same HTTP status and message.
🤖 This PR was written by Claude Code (Claude Fable 5).