zeroshade commented on code in PR #1399:
URL: https://github.com/apache/iceberg-go/pull/1399#discussion_r3553634248
##########
cmd/iceberg/branch_tag.go:
##########
@@ -197,6 +241,26 @@ func runTagCreate(ctx context.Context, output Output, cat
catalog.Catalog, cmd *
output.RefCreated(result)
}
+func validateRefName(name string) error {
+ if strings.TrimSpace(name) != name || name == "" {
+ return errors.New("name must be non-empty and may not contain
leading/trailing whitespace")
+ }
+
+ if name == "." || name == ".." {
+ return errors.New("name may not be '.' or '..'")
+ }
+
+ if strings.ContainsAny(name, "/\\") {
Review Comment:
Rejecting `/` is stricter than the Iceberg spec / Java / Spark / PyIceberg,
which allow slash-style ref names (e.g. `audit/foo`) common in WAP workflows.
If this is intentional (e.g. Spark selector concerns), a short comment
explaining why would help; otherwise consider relaxing it.
##########
cmd/iceberg/branch_tag_test.go:
##########
@@ -109,6 +110,158 @@ func TestTextOutputRefCreated(t *testing.T) {
assert.Contains(t, output, "5000")
}
+func TestRunBranchCreateRejectsNegativeRetentionValues(t *testing.T) {
+ tbl := branchTagTestTable(t)
+ cat := &branchTagCommitCatalog{tbl: tbl}
+ out := &refCreatedCapture{}
+
+ exitCode := captureBranchTagExit(func() {
+ runBranchCreate(context.Background(), out, cat,
&BranchCreateCmd{
+ TableID: "db.events",
+ BranchName: "new-feature",
+ MaxRefAge: "-1d",
Review Comment:
`-1d` isn't a valid Go duration (`time.ParseDuration` supports
ns/us/ms/s/m/h, not `d`), so this hits the parse-error branch rather than the
`d <= 0` guard it's meant to exercise — the assertion passes for the wrong
reason. The tag test correctly uses `-12h`; use a valid negative duration like
`-1h` here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]