Skip to content

fix(linear): route comment webhooks with project scope#1157

Merged
zbigniewsobiecki merged 1 commit intomongrel-intelligence:devfrom
maksymilian-majer:fix/linear-comment-webhook-routing
Apr 22, 2026
Merged

fix(linear): route comment webhooks with project scope#1157
zbigniewsobiecki merged 1 commit intomongrel-intelligence:devfrom
maksymilian-majer:fix/linear-comment-webhook-routing

Conversation

@maksymilian-majer
Copy link
Copy Markdown
Contributor

Summary

  • Fix Linear comment webhooks whose issue context is nested under data.issue, including teamId and project scope resolution.
  • Fetch the issue project from Linear when scoped comment events omit project data, so project-scoped triggers still match.
  • Resolve Linear bot identity aliases and accept plain @handle comment mentions alongside Linear UUID-style mentions.

Test Plan

  • Unit tests pass (npm test via npm run verify)
  • Linter passes (npm run lint via npm run verify)
  • Type check passes (npm run typecheck via npm run verify)
  • Pre-push fast test hook passed (npm run test:fast -- --changed origin/dev)
  • Tested manually: local Docker/ngrok Linear webhook for TF-6; a Linear comment with @cascade queued the respond-to-feedback flow and posted the expected acknowledgement.

Checklist

  • My code follows the project code style
  • I have added tests for new functionality
  • I have updated documentation if needed (not needed; behavior-only fix)
  • My commits follow Conventional Commits

@zbigniewsobiecki zbigniewsobiecki requested a review from aaight April 22, 2026 08:27
Copy link
Copy Markdown
Collaborator

@nhopeatall nhopeatall left a comment

Choose a reason for hiding this comment

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

Summary

LGTM — Clean, well-tested bug fix for three real Linear webhook routing issues. Each fix is correctly scoped and follows existing codebase patterns.

What the PR does well:

  1. Nested teamId extraction (data.issue.teamId fallback) — correctly handles Linear Comment/IssueLabel webhooks that don't repeat teamId at the data root.

  2. Project scope fetch fallback — when the payload omits projectId/project, the adapter fetches it via a new linearClient.getIssueProjectId() GraphQL query, with proper credential resolution and error handling. The fallback is narrowly scoped to comment events only, which is appropriate.

  3. Plain @handle mention matching — the hasMention function now checks stable bot identity aliases (name, displayName, email local-part) in addition to UUID substring matching. The regex /@([A-Za-z0-9._-]+)/g correctly ignores Linear's @[Display Name](uuid) markdown syntax since [ isn't in the character class.

  4. resolveLinearBotIdentity — widens the cached viewer query to fetch name, email, displayName alongside id. The existing resolveLinearBotUserId correctly delegates to the new function, and the isSelfAuthored path in the adapter continues to use the ID-only version.

  5. Test coverage is thorough — 87 tests pass across the 4 changed test files, covering nested teamId routing, project fetch fallback, identity caching, alias matching (including email local-part edge case), and null/error paths. The PM conformance harness (72 passing) confirms no regressions.

🕵️ claude-code · claude-opus-4-6 · run details

@zbigniewsobiecki zbigniewsobiecki merged commit 2ccc428 into mongrel-intelligence:dev Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants