fix(ticket-sync): workspace awareness and auth error handling#524
fix(ticket-sync): workspace awareness and auth error handling#524nethi wants to merge 4 commits intojonwiggins:mainfrom
Conversation
Without a workspaceId, getRepoByUrl only looked in the 'default' slug workspace. Background jobs like ticket sync have no workspace context, so repos in user-created workspaces were never found — causing tasks to fall back to claude-code regardless of the configured default agent type. Added a three-tier fallback: default workspace → NULL workspace_id → any workspace. Also surfaces secret retrieval failures in ticket sync as warnings instead of swallowing them silently. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…revent reconcile loops
- Remove in-memory sort by createdAt in repo-service and ticket-sync - Add warning when multiple repos found across workspaces - Add warning when repo config not found in ticket-sync - Pass workspaceId to createTask to ensure correct workspace assignment - Remove unused desc imports This ensures background jobs like ticket-sync work correctly with multi-workspace setups without breaking test cases.
jonwiggins
left a comment
There was a problem hiding this comment.
The retryable-flip on auth errors is exactly the right call, and the new GEMINI_API_KEY pattern is welcome.
One correctness concern though: the new "any workspace" fallback in apps/api/src/services/repo-service.ts:144-160 affects every unscoped caller of getRepoByUrl, not just ticket-sync. The current callers that pass no workspaceId (or sometimes-null workspaceId) include:
task-service.ts:633review-service.ts:94subtask-service.ts:186dependency-service.ts:218
In a multi-tenant deploy with the same repo URL configured across workspaces, this means any of these paths could now resolve to the wrong row. Single-workspace deploys are fine, but as a default this is a soft data-leak surface.
Could you gate the cross-workspace tier behind an explicit opt-in — e.g., getRepoByUrl(url, { workspaceId, allowAnyWorkspace: true }) — and only have ticket-sync pass it? The warning log helps detection but doesn't prevent the wrong resolution.
Also (small ask, not blocking): a regression test pinning retryable: false on the auth patterns in error-classifier.test.ts would make a future revert loud.
Summary
Fixes ticket-sync workspace awareness and prevents reconcile loops caused by missing API keys (including Gemini).
Problem
claude-codeagent regardless of repo configurationretryable: true, causing tasks to retry indefinitelyChanges
Multi-workspace repo resolution (
repo-service.ts)getRepoByUrlwhen noworkspaceIdspecified:Ticket-sync workspace awareness (
ticket-sync-service.ts)configuredReposquery from selecting only{ repoUrl }to full repo recordsworkspaceId: repoConfig?.workspaceIdtocreateTaskfor correct workspace assignmentAPI key error handling (
error-classifier.ts)retryable: true→retryable: falsefor all auth errors:retryable: false/Secret not found: (\w+)|no (\w+) secret found/iTesting
Files Changed
apps/api/src/services/repo-service.ts- Multi-workspace fallback logicapps/api/src/services/ticket-sync-service.ts- Workspace-aware task creationpackages/shared/src/error-classifier.ts- Auth error handling + Gemini supportFixes ticket-sync workspace detection and prevents infinite retries on auth failures.