diff --git a/shortcuts/doc/docs_update_v2.go b/shortcuts/doc/docs_update_v2.go index 1e08b6b81..987dca2bf 100644 --- a/shortcuts/doc/docs_update_v2.go +++ b/shortcuts/doc/docs_update_v2.go @@ -145,6 +145,14 @@ func validateBlockDeleteIDs(raw string) error { return nil } +func normalizeBlockDeleteIDs(raw string) string { + parts := strings.Split(raw, ",") + for i := range parts { + parts[i] = strings.TrimSpace(parts[i]) + } + return strings.Join(parts, ",") +} + func dryRunUpdateV2(_ context.Context, runtime *common.RuntimeContext) *common.DryRunAPI { // Validate has already accepted --doc; parseDocumentRef cannot fail here. ref, _ := parseDocumentRef(runtime.Str("doc")) @@ -220,6 +228,9 @@ func buildUpdateBodyBase(runtime *common.RuntimeContext) map[string]interface{} body["pattern"] = v } if blockID != "" { + if cmd == "block_delete" { + blockID = normalizeBlockDeleteIDs(blockID) + } body["block_id"] = blockID } if v := runtime.Str("src-block-ids"); v != "" { diff --git a/tests/cli_e2e/docs/docs_update_dryrun_test.go b/tests/cli_e2e/docs/docs_update_dryrun_test.go index 39da9b862..33ba74549 100644 --- a/tests/cli_e2e/docs/docs_update_dryrun_test.go +++ b/tests/cli_e2e/docs/docs_update_dryrun_test.go @@ -91,10 +91,11 @@ func TestDocs_DryRunDefaultsToV2OpenAPI(t *testing.T) { "docs", "+update", "--doc", "doxcnDryRunE2E", "--command", "block_delete", - "--block-id", "blkA,blkB,blkC", + "--block-id", "blkA, blkB, blkC", "--dry-run", }, wantContains: []string{"/open-apis/docs_ai/v1/documents/doxcnDryRunE2E"}, + wantBody: map[string]any{"block_id": "blkA,blkB,blkC"}, }, { name: "history list",