Repository navigation
fix(sync-service): allow DELETE /v1/shape to resolve a shape by its definition - #4754
Merged
Merged
Conversation
…efinition DeleteShapePlug narrowed the incoming params to ["table", "handle"] before handing them to Api.validate_for_delete/2, dropping where/columns/params/ replica/log. The shape passed to Shapes.fetch_handle_by_shape/2 was therefore always the bare-table shape, so any shape defined with a where clause or a column selection could only ever be deleted by handle. Widen the take list to every param that Api.Params.define_shape/2 reads and add plug- and router-level regression tests; the existing api_test.exs coverage calls validate_for_delete/2 directly and so bypasses the plug. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
doesn't seem like this is used anymore
Removed the @shape_definition_params constant and updated the parameter handling in validate_request.
…tions Build query strings with URI.encode_query/1 (as serve_shape_plug_test.exs does) instead of hand-rolled URI.encode_www_form/1 interpolation, and hoist the stub inspector into an @inspector module attribute, matching the other plug tests. Also move the explanatory comment inside validate_request/2 so it sits with the Map.take/2 it describes, and restore the changeset entry required by the Check Changeset workflow for any PR touching packages/sync-service. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The hand-maintained `Map.take` list duplicated the field list of the
`Api.Params` Ecto schema, and that duplication is what caused the
original bug: the list silently rotted as new shape-defining parameters
were added. Ecto's `cast` already drops unknown parameters, and
`validate_for_delete/2` deliberately ignores request-only fields such as
`offset` and `live`, so the plug can pass the merged query/path params
through wholesale.
Also remove the `Map.put("offset", "-1")` — nothing on the delete path
reads `offset`; it is a leftover from when the delete plug reused the
general `Params.validate/2`.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Request-only params such as `live` are ignored by delete validation but still go through schema casting, so a malformed value returns a 400 instead of being silently dropped. Pin that down as expected behaviour. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
alco
approved these changes
Aug 12, 2026
alco
left a comment
Contributor
There was a problem hiding this comment.
Thanks for the contribution! I've adjusted the implementation a bit for future-proofing.
✅ Deploy Preview for electric-next ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4754 +/- ##
==========================================
- Coverage 60.01% 59.21% -0.81%
==========================================
Files 397 379 -18
Lines 43766 42653 -1113
Branches 12588 12335 -253
==========================================
- Hits 26268 25257 -1011
+ Misses 17416 17354 -62
+ Partials 82 42 -40
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
|
This PR has been released! 🚀 The following packages include changes from this PR:
Thanks for contributing to Electric! |
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.
DeleteShapePlug narrowed the incoming params to ["table", "handle"] before handing them to Api.validate_for_delete/2, dropping where/columns/params/ replica/log. The shape passed to Shapes.fetch_handle_by_shape/2 was therefore always the bare-table shape, so any shape defined with a where clause or a column selection could only ever be deleted by handle.
Widen the take list to every param that Api.Params.define_shape/2 reads and add plug- and router-level regression tests; the existing api_test.exs coverage calls validate_for_delete/2 directly and so bypasses the plug.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.