Skip to content

feat: align admin cmds#2045

Open
freeznet wants to merge 10 commits intomasterfrom
freeznet/align-admin-cmds
Open

feat: align admin cmds#2045
freeznet wants to merge 10 commits intomasterfrom
freeznet/align-admin-cmds

Conversation

@freeznet
Copy link
Copy Markdown
Member

(If this PR fixes a github issue, please add Fixes #<xyz>.)

Fixes #

(or if this PR is one task of a github issue, please add Master Issue: #<xyz> to link to the master issue.)

Master Issue: #

Motivation

Explain here the context, and why you're making that change. What is the problem you're trying to solve.

Modifications

Describe the modifications you've done.

Verifying this change

  • Make sure that the change passes the CI checks.

(Please pick either of the following options)

This change is a trivial rework / code cleanup without any test coverage.

(or)

This change is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end deployment with large payloads (10MB)
  • Extended integration test for recovery after broker failure

Documentation

Check the box below.

Need to update docs?

  • doc-required

    (If you need help on updating docs, create a doc issue)

  • no-need-doc

    (Please explain why)

  • doc

    (If this PR contains doc changes)

@freeznet freeznet self-assigned this Apr 10, 2026
@freeznet freeznet requested review from a team, mattisonchao, nlu90 and zymap as code owners April 10, 2026 16:13
Copilot AI review requested due to automatic review settings April 10, 2026 16:13
@github-actions
Copy link
Copy Markdown

@freeznet:Thanks for your contribution. For this PR, do we need to update docs?
(The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)

@github-actions github-actions bot added the doc-info-missing This pr needs to mark a document option in description label Apr 10, 2026
Copy link
Copy Markdown

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown

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

Copilot reviewed 59 out of 60 changed files in this pull request and generated 5 comments.


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

Comment on lines +71 to +74
timestamp, err := time.Parse(time.RFC3339Nano, datetime)
if err != nil {
return err
}
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

--datetime help text says RFC3339 or RFC3339Nano, but the implementation parses using time.RFC3339Nano only. time.Parse(time.RFC3339Nano, ...) will reject RFC3339 timestamps without fractional seconds (e.g. 2021-06-28T16:53:08Z). Consider accepting both formats (try RFC3339Nano then RFC3339) or update the flag description/examples to match the supported format.

Copilot uses AI. Check for mistakes.
Comment on lines +57 to +59
vc.FlagSetGroup.InFlagSet("SchemaCompatibilityStrategy", func(set *pflag.FlagSet) {
set.StringVarP(&strategy, "compatibility", "c", "", "schema compatibility strategy")
})
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

--compatibility is optional here, but utils.ParseSchemaCompatibilityStrategy(strategy) will fail (or potentially default unexpectedly) when the flag is omitted/empty. This should be treated as a required input (e.g., mark the flag required) to provide a clearer CLI contract and error message.

Copilot uses AI. Check for mistakes.
Comment on lines +57 to +59
vc.FlagSetGroup.InFlagSet("ReplicationClusters", func(set *pflag.FlagSet) {
set.StringVarP(&clusterIDs, "clusters", "c", "", "comma separated cluster names")
})
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

--clusters isn't required, so running the command without it will call strings.Split("", ",") and send a slice containing an empty string to the admin API. Mark the flag required and/or validate non-empty cluster names before calling SetReplicationClusters.

Copilot uses AI. Check for mistakes.
Comment thread pkg/ctl/namespace/admin_http.go Outdated
Comment on lines +57 to +59
escapedParts := make([]string, len(parts))
for i, part := range parts {
escapedParts[i] = url.PathEscape(part)
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

namespaceAdminEndpoint applies url.PathEscape to each path part. Passing ns.String() (which contains a /) will encode it as %2F, which some HTTP servers/frameworks reject or route differently (encoded slashes are often blocked). Consider building the endpoint from tenant + namespace segments (or splitting ns.String() on / and escaping each segment) so the request path matches Pulsar's expected /namespaces/{tenant}/{namespace}/... format reliably.

Suggested change
escapedParts := make([]string, len(parts))
for i, part := range parts {
escapedParts[i] = url.PathEscape(part)
escapedParts := make([]string, 0, len(parts))
for _, part := range parts {
for _, segment := range strings.Split(part, "/") {
escapedParts = append(escapedParts, url.PathEscape(segment))
}

Copilot uses AI. Check for mistakes.
Comment thread pkg/ctl/topicpolicies/test_help.go Outdated
Comment on lines +28 to +37
func TestTopicPoliciesCommands(newVerb func(cmd *cmdutils.VerbCmd), args []string) (out *bytes.Buffer, execErr, nameErr, err error) {
var execError error
cmdutils.ExecErrorHandler = func(err error) {
execError = err
}

var parsedNameError error
cmdutils.CheckNameArgError = func(err error) {
parsedNameError = err
}
Copy link

Copilot AI Apr 15, 2026

Choose a reason for hiding this comment

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

This helper overwrites the global cmdutils.ExecErrorHandler and cmdutils.CheckNameArgError but never restores the previous handlers. That can leak state between tests and make failures order-dependent. Capture the old values and restore them via defer/t.Cleanup.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-info-missing This pr needs to mark a document option in description

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants