Skip to content

Handle repo label rename/delete#177

Merged
anderdc merged 2 commits into
entrius:testfrom
MkDev11:fix/repo-label-rename-delete
Jun 24, 2026
Merged

Handle repo label rename/delete#177
anderdc merged 2 commits into
entrius:testfrom
MkDev11:fix/repo-label-rename-delete

Conversation

@MkDev11

@MkDev11 MkDev11 commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Summary

Handle repository-level label rename/delete webhooks so scoring-visible label state stays aligned with GitHub.

Root cause: label webhook events were skipped as repo-level CRUD, but miner responses derive current PR/issue labels from label_events through pr_labels_by_actor and issue_labels_by_actor. When a repo label was deleted or renamed, the mirror had no repo-wide transition to remove or rename the current per-target label rows.

This PR:

  • routes repo-level label events into LabelHandler
  • records unlabeled tombstones for currently applied labels when a repo label is deleted
  • records an old-name unlabeled plus new-name labeled transition when a repo label is renamed
  • preserves the original label actor on renamed labels so actor attribution remains stable
  • keeps parent pull_requests.labels and issues.labels arrays in sync

Out of scope: a full repo_labels catalog for color/description/default-label metadata.

Related Issues

Addresses the stale scoring-label state from #101.

Type of Change

  • Bug fix
  • New feature
  • Refactor
  • Documentation
  • Other (describe below)

Testing

  • npm run format:check
  • npm run lint
  • npm run build
  • git diff --check

No automated test suite is configured in packages/das/package.json.

Checklist

  • I have read the Contributing Guide
  • Code builds without errors
  • New and existing tests pass (if applicable)
  • Documentation updated (if applicable)
  • No unnecessary dependencies added

@xiao-xiao-mao xiao-xiao-mao Bot added the bug Something isn't working label Jun 8, 2026
@MkDev11

MkDev11 commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

@anderdc can you please review the pr?

@anderdc anderdc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The two new repo-label handlers drop to raw manager.query SQL, but the rest of this file uses the TypeORM repository API (handle(), label.handler.ts:42-74). Please match that style. The behavior and the append-only transition design are correct as-is — this is consistency only, no logic change.

  • removeRepoLabel / renameRepoLabel: replace dataSource.transaction(manager.query(...)). Find the currently-labeled targets with a SelectQueryBuilder using .distinctOn(["repo_full_name","target_number","target_type","label_name"]) ordered by timestamp DESC, filtered to action = 'labeled'.
  • Insert the transition rows via labelEventRepo.createQueryBuilder().insert().values([...]).orIgnore() instead of the INSERT ... SELECT ... ON CONFLICT.
  • Parent arrays: prRepo/issueRepo .createQueryBuilder().update().set({ labels: () => "array_remove(labels, :name)" }).where(":name = ANY(labels)") — keep only the array_remove / array_replace / = ANY fragments raw, since no ORM abstracts Postgres array operators.

This also lets you drop the raw-query eslint-disable and keeps the handler reading like handle().

@MkDev11 MkDev11 requested a review from anderdc June 23, 2026 04:57
@anderdc anderdc merged commit cbd6184 into entrius:test Jun 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants