Skip to content

feat(tags): Add support to bulk unassign tags - #75

Merged
Rutvik G (rutvik-gs) merged 5 commits into
feat/tagsfrom
feat/tags-12-bulk-unassign
Jul 30, 2026
Merged

feat(tags): Add support to bulk unassign tags#75
Rutvik G (rutvik-gs) merged 5 commits into
feat/tagsfrom
feat/tags-12-bulk-unassign

Conversation

@rutvik-gs

@rutvik-gs Rutvik G (rutvik-gs) commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Problem

tags assign --query gave us bulk tagging, but there was no way to bulk untag. So this PR adds that. Similarly, there was also no way to stop a bulk job once submitted. A mistyped CenQL query on a broad corpus had to run to completion, and operations could only watch it happen. Hence cancel operation support was also added.

Technical Changes

  • tags unassign gains a bulk mode — --all removes every assignment, --created-before/--created-after remove a window. Either submits a bulk_delete job and reports the tracking operation, with --wait/--timeout reusing the shared poll loop. Bulk is entered only by those flags, never inferred from missing asset arguments, and cannot be combined with explicit assets or --input-file. --all can't be narrowed by a time filter — that combination contradicts itself and is rejected.
  • tags operations cancel <tag> <op-id> — new subcommand, confirms unless --yes. Deliberately does not treat a cancelled status as a failure the way --wait does: a successful cancel exits 0. Cancelling is not a rollback, and the prompt says so.
  • internal/pkg/clients/censys/tags.goBulkDeleteTagAssignments (absent timestamps send an empty body, which is the API's "delete ALL") and CancelTagOperation.
  • Shared, not duplicated — the just-submitted-job wait path is now one followSubmittedOperation used by both bulk assign and bulk unassign, so the interrupt-vs-track-hint branch can't drift. ValidateTimeWindow is exported so unassign rejects an inverted window in PreRun and the service keeps its guard — the same double-validation assign uses for a blank --query, which is what lets it fail before credentials are needed.

How to Test

Fast path:

make mocks && git diff --exit-code   # generated code must be in sync
make all && make cover-check
make e2e

Live walkthrough — self-cleaning, one uniquely named tag:

export PATH="$PWD/bin:$PATH"
TAG="demo-$(date +%H%M%S)"
censys tags create "$TAG" --privacy private
censys tags assign "$TAG" 8.8.8.8
censys tags get "$TAG" --asset-count          # Assets: 1
censys tags unassign "$TAG" --all --wait --yes # 202 → succeeded, 1/1
censys tags operations list "$TAG" --type bulk_delete
censys tags delete "$TAG" --yes

@rutvik-gs
Rutvik G (rutvik-gs) marked this pull request as ready for review July 30, 2026 12:24
@rutvik-gs
Rutvik G (rutvik-gs) requested a review from a team as a code owner July 30, 2026 12:24
@rutvik-gs
Rutvik G (rutvik-gs) changed the base branch from feat/tags-11-bulk-assign to feat/tags July 30, 2026 12:28
@rutvik-gs
Rutvik G (rutvik-gs) force-pushed the feat/tags-12-bulk-unassign branch from 511a854 to ed7a081 Compare July 30, 2026 12:34

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@rutvik-gs
Rutvik G (rutvik-gs) merged commit 9f7fcd0 into feat/tags Jul 30, 2026
2 checks passed
@btschwartz12
Ben Schwartz (btschwartz12) deleted the feat/tags-12-bulk-unassign branch July 30, 2026 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants