Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v23.3.x] admin/transform/delete: path decode names #16885

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/go/rpk/pkg/adminapi/api_transform.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"encoding/json"
"io"
"net/http"
"net/url"
)

const (
Expand All @@ -35,7 +36,7 @@ func (a *AdminAPI) DeployWasmTransform(ctx context.Context, t TransformMetadata,

// DeleteWasmTransform deletes a wasm transform in a cluster.
func (a *AdminAPI) DeleteWasmTransform(ctx context.Context, name string) error {
return a.sendToLeader(ctx, http.MethodDelete, baseTransformEndpoint+name, nil, nil)
return a.sendToLeader(ctx, http.MethodDelete, baseTransformEndpoint+url.PathEscape(name), nil, nil)
}

// PartitionTransformStatus is the status of a single transform that is running on an input partition.
Expand Down
7 changes: 6 additions & 1 deletion src/v/redpanda/admin/transform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "json/validator.h"
#include "redpanda/admin/api-doc/transform.json.hh"
#include "redpanda/admin/server.h"
#include "redpanda/admin/util.h"
#include "transform/api.h"

#include <system_error>
Expand Down Expand Up @@ -45,7 +46,11 @@ admin_server::delete_transform(std::unique_ptr<ss::http::request> req) {
if (!_transform_service->local_is_initialized()) {
throw transforms_not_enabled();
}
auto name = model::transform_name(req->param["name"]);
ss::sstring raw_name;
if (!admin::path_decode(req->param["name"], raw_name)) {
throw seastar::httpd::bad_request_exception("invalid transform name");
}
auto name = model::transform_name(std::move(raw_name));
std::error_code ec = co_await _transform_service->local().delete_transform(
std::move(name));
co_await throw_on_error(*req, ec, model::controller_ntp);
Expand Down
Loading