Repository navigation
Jira/multi account support - #708
batoolfatima05 wants to merge 235 commits into
Conversation
Baseline documentation for the Clustox fork of middlewarehq/middleware. - ARCHITECTURE.md: system architecture covering the container and component model, data model, sync pipeline, DORA metric derivations, and known constraints. Every structural claim is reproducible via the commands in Appendix A. - FORK_STRATEGY.md: upstream maintenance strategy -- remotes, branch model, the three-tier rule for where Clustox changes may live, the monthly sync runbook, and Apache 2.0 obligations. - UPSTREAM_SYNC_LOG.md: ledger for recording each upstream merge. - NOTICE: Apache 2.0 s4(d) attribution, absent upstream and required once a modified version is distributed. - superpowers/specs + plans: design and implementation plan for authentication and role-based access control. Two findings documented in detail: - Two independent write paths reach the same database. The Next.js BFF goes directly to Postgres via knex in 23 files rather than through the Flask API, with its own hand-maintained schema copy in TypeScript. - There is no authentication anywhere in the stack. next-auth is a dependency but is never configured: no route, no sign-in page. Also documents the sync bookmark behaviour (ARCHITECTURE.md 7.5), where a newly added repo silently syncs no history while the UI shows "Calculating Dora" indefinitely.
CLUSTOX: new tables rather than columns on upstream's Users, so upstream migrations can never collide with ours. Role values are constrained at the database level via a CHECK, verified to reject invalid values independently of the foreign key. schema.sql regenerated by dbmate; the diff is purely additive.
bcryptjs rather than bcrypt: pure JS, no native compilation, so the Docker build is unaffected. Cost factor 12. verifyPassword swallows malformed-hash errors and returns false, so a corrupt stored hash can never be mistaken for a successful comparison.
Authorization decisions live here so routes stay thin. Superadmin short-circuits every team check without a query; admins are checked against ClustoxUserTeamAccess per request rather than from the token, so a permission change takes effect immediately.
JWT sessions carry userId and role only. Team assignments are read from the database per request instead, so changing someone's teams takes effect immediately rather than at next login. Session lifetime 12h, no sliding renewal.
Upstream declared `authenticated: boolean = true` on Endpoint and
accepted an { unauthenticated: true } opt-out, but serve() never read
the flag. Five routes already opted out correctly, so the mechanism was
clearly intended to be enforced.
Reading it here covers all 47 BFF routes from one insertion point --
every real API route goes through Endpoint (the four non-Endpoint files
under pages/api are helper modules with no default export).
Test baseline: git_org_repos.test.ts and array.test.ts fail identically
on upstream's own global.ts and are unrelated to auth. Verified with
--runInBand; parallel workers give flaky counts on this suite.
Two corrections found during verification: - middleware must NOT redirect /api/* requests. Endpoint.serve() already returns 401 for those, and redirecting an XHR to an HTML login page surfaces as a parse error rather than an auth failure. - _app.tsx gated every page on auth.isInitialized, which AuthProvider sets only after a session fetch that now requires a session. That made the login page unreachable: the app waited forever for a login it would not render the form for. The gate is now bypassed on /login. This makes _app.tsx an eighth modified upstream file, one more than the plan estimated.
Two upstream files needed changes that the plan did not anticipate: - next.config.js: knex resolves dialects dynamically, which webpack cannot bundle, so the instrumentation hook failed to compile and the bootstrap never ran. Fixed with serverExternalPackages: ['knex','pg']. API routes were unaffected, so this only surfaced once instrumentation started importing the db helper. - ThirdPartyAuthContext.tsx: fetchSession had no .catch(), so the now-401 session request rejected unhandled and buried the login page under a runtime error overlay. A 401 there is the expected unauthenticated case; it now falls through to the provider's existing onUnauthenticated path. No default password: absent env vars log loudly and create nothing, rather than falling back to a known value. Verified end to end in a browser: unauthenticated request redirects to /login, superadmin signs in, dashboards render with live data.
This is what makes the auth real rather than cosmetic. Before this, curl http://localhost:9696/teams/<id>/lead_time returned full metrics with no credentials, bypassing every guard added so far. Fails closed: an unset INTERNAL_API_TOKEN rejects all requests rather than allowing them. hmac.compare_digest avoids leaking the token through response timing. Health endpoints stay exempt so container and UI status probes keep working. Cron needed its own path: it does not inherit the container environment, so it now runs trigger_sync.sh which sources /app/.env and sends the header. This was the highest-risk step -- a broken sync reports HTTP 200 regardless of outcome -- so it was verified by running the helper and confirming a full sync completed. Verified: direct :9696 and :9697 -> 403, health -> 200, correct token -> 200, cron sync completes, dashboards still render in the browser. 155 pytest tests pass.
Deviation from the plan, deliberately: rather than adding an assertTeamAccess call to each of the 18 team-scoped routes, the check runs centrally in Endpoint.serve() whenever the payload carries a team_id. One file instead of eighteen, and a newly added team route is protected by default rather than depending on the author remembering. Team list endpoints still need explicit filtering since they carry no team_id, so index.ts and v2.ts filter through getAccessibleTeamIds. Team creation and integration deletion are superadmin-only. share.ts is no longer unauthenticated: it allowed anonymous POSTs that inserted unbounded rows into URLShortenerData. Verified live as an admin scoped to ZDA only: own team team_repos -> 200 other team team_repos -> 403 other team dora_metrics -> 403 team list -> ['ZDA'] only 152 jest tests pass; the 2 failing suites fail identically on upstream.
Superadmin-only. Creates users with a role and team assignments, and edits team scoping inline from the table. Guards beyond the plan: - duplicate email returns 409 rather than creating a shadow account - a superadmin cannot demote themselves when they are the last one, which would leave the instance unadministerable through the UI - 12-character minimum enforced in the yup schema, so the UI cannot create a weak account The page derives its own authorisation from the API's 403 rather than from AuthContext, whose role field is hardcoded to UserRole.MOM upstream. That avoids another upstream edit and keeps the server as the single source of truth. Verified live: weak password 400, duplicate email 409, valid create 200, admin gets 403 on the users API and sees 'Not authorised' on the page.
Playwright spec covers the redirect, credential rejection, 401 on unauthenticated API calls, 403 on direct Flask access, and reachable health endpoints. The four request-level tests pass in the dev container. The three page-level tests need Chromium system libraries the middleware-dev image does not ship -- 'playwright install --with-deps' fails on this Debian base -- so they are documented as host/CI-only. Every behaviour they cover was verified manually against a real browser. Docs corrected: the spec estimated six modified upstream files; the real figure is 19 (12 carrying genuine logic changes). The estimate missed every file that only reveals itself at runtime -- the _app.tsx auth gate, the knex/webpack conflict, the unhandled session rejection, and the cron path. The original estimate is kept alongside the correction because the gap is the useful part. UPSTREAM_SYNC_LOG.md now records the divergence baseline (19 modified, 26 new, 33 sentinels) so the first upstream merge has something to check against.
A JWT proves only that someone signed in at some point. It says nothing about whether the account still exists or still holds the role it had at sign-in. getAuthSession trusted it for both. Two consequences, one found by a user report: - A deleted user kept a valid session. Team access was already read per-request, so they lost data (403) but stayed 'logged in' -- landing them in an app with no teams, no repos and no metrics. That reads as data loss, not as an auth failure. - Role lived in the token, so demoting a superadmin left them with superadmin powers until the token expired, up to 12 hours. Both now resolve from the database on every request, matching how team access already worked. Leaving identity and role in the token while reading team access live was an inconsistency in the original design. Cost is one indexed lookup per request. Verified against a live session for a user deleted mid-session: was 200 on /api/auth/session and 403 on team data, now 401 on both, so the middleware redirects to login instead of showing an empty app.
Two gaps from the plan, both reported by the user. The plan specified a /users page but never said how anyone would reach it, and never addressed sign out at all -- upstream has no logout affordance because it had no login. - Sidebar footer shows who is signed in with their role, plus a Sign out button. - 'Manage Users' nav item, hidden from non-superadmins. Sidebar visibility reads the real role from a new /api/clustox/me endpoint rather than AuthContext, whose role field upstream hardcodes to UserRole.MOM. Hiding the item is presentation only; the API returns 403 regardless of what the sidebar shows. Verified: superadmin sees Manage Users and the Superadmin chip, Sign out redirects to /login. 156 jest tests pass.
Add Jenkinsfile for CI/CD pipeline
jenkins file updated
Records the gap between the shipped auth work (scoped by team) and the multitenant model agreed in the first meeting (scoped by workspace), the six open decisions, and cost estimates. Decision received: Admins connect their own integrations.
jenkins file updated
jenkins file updated
Each ADMIN owns a workspace (an Organization); a SUPERADMIN owns none and sits above all of them. No schema change was needed. Upstream's Users.org_id already exists and is already nullable, every other table already carries org_id, and Integration is keyed on (name, org_id) -- so one GitHub account per workspace is how the schema was already built. Upstream simply only ever created a single Organization named 'default'. - AuthSession carries orgId, resolved per-request from the database alongside identity and role - createUser provisions a workspace for an ADMIN, or accepts an existing one so the pre-multitenancy workspace can be adopted rather than discarded - SUPERADMIN is created with no workspace; the migration also clears the workspace from any existing superadmin, which would otherwise scope their view to it 42 auth tests pass.
Access now derives from workspace ownership rather than per-team grants. An admin sees everything in the workspace they own and nothing outside it; a superadmin sees across all of them. - assertWorkspaceAccess gates any route carrying org_id - assertTeamAccess resolves the team's workspace instead of consulting ClustoxUserTeamAccess, so an admin reaches every team in their own workspace without needing individual grants - both run centrally in Endpoint.serve(), so a newly added route is scoped by default - the BFF session returns the caller's own workspace; upstream took whichever Organization came back first, correct only while one existed - a missing team is refused rather than 404'd, so an admin cannot probe for team ids outside their workspace ClustoxUserTeamAccess is left in place unused. Sub-workspace scoping can be reinstated later without a migration if a workspace grows enough to need it. Verified live with two workspaces: superadmin session -> no workspace create admin -> new workspace provisioned admin session -> own workspace, no integrations admin -> other workspace -> 403 (teams, team data, users api) superadmin -> both -> 200, sees all teams in each 163 jest and 155 pytest tests pass.
Regression from the previous commit. A superadmin owns no workspace, so session.org was null, integrationList was empty, and the sidebar filter collapsed to just 'Manage Integrations' while the router forced them onto that page. The app looked unconfigured. The whole UI is workspace-scoped, so a superadmin needs a workspace to look at even though they own none: - /api/clustox/workspaces lists all workspaces and records a selection - the session resolves that selection, falling back to the oldest workspace, and ignores a stale one that no longer exists - a workspace switcher in the sidebar footer, superadmin only - superadmin is exempt from the onboarding redirects and the integration-required sidebar filter, which describe a workspace they are merely viewing The selection is viewing context only. Guards never consult it -- a superadmin passes every workspace check regardless of what is selected.
Two problems, both reported from actual use. The sidebar and header were missing because the page never used PageWrapper, which is where every other page gets its chrome. Setting getLayout to ExtendedSidebarLayout alone was not enough. The table was also stale: it still showed a Teams column with an empty dropdown, left over from the pre-multitenancy model. Under tenancy an admin belongs to a workspace, not to a list of teams, so the column was both meaningless and misleading -- the one fact this page exists to show was the one it did not show. Rebuilt around the current model: - Workspace column, rendered monospaced so tenancy reads as data - superadmins show 'All workspaces' rather than an empty cell - add-user moved into a dialog; the inline five-field row was cramped and permanently on screen for an occasional action - the role toggle explains what each role actually gets, since the difference is workspace ownership and that is not self-evident - password validation gives a live character count instead of failing on submit - role changes moved to a row menu, with the last-superadmin refusal surfaced as a message rather than a silent no-op - empty state, and counts of admins and workspaces 165 tests pass.
An admin creating a GitHub integration got a 403. The request was going to /api/resources/orgs/undefined/integration -- the client had no workspace id to send. Root cause was the client, not the API: the modal read orgId from redux, which redux-persist rehydrates from the previous session. During the window where a superadmin's session legitimately returned no workspace, that empty value was persisted and survived into the next login. - /api/clustox/me now returns the caller's workspace, resolved server-side per request and never persisted - both provider modals prefer it over the redux copy, and refuse to submit without a workspace rather than posting 'undefined' Also corrected the order of checks in Endpoint.serve(). Workspace and team scoping ran before schema validation, so a malformed org id surfaced as an opaque 403 instead of a 400 naming the bad field. That made this take far longer to diagnose than it should have. Validation now runs first. Verified live as an admin: link to own workspace -> 200, stored against their workspace link to another workspace -> 403 malformed workspace id -> 400 (was 403) Each workspace now holds its own GitHub integration, which is what Integration's (name, org_id) key was always designed for.
…s-tenant hole
Creating a team in your own workspace returned 403. I had restricted
team creation and integration removal to superadmins, which was right
under the old shared-workspace model and wrong under this one: an admin
owns their workspace, so teams and integrations inside it are theirs to
manage. Shahzad confirmed admins connect their own integrations.
Both restrictions removed. The central check on org_id already confines
an admin to their own workspace, which is the control that matters.
Removing them surfaced a worse problem. teams/v2 names the team 'id',
not 'team_id', so the central team scoping never saw it. An admin could
pass their own org_id in the path -- satisfying the workspace check --
together with a team id from another workspace, and edit or delete it.
PATCH and DELETE now assert team access explicitly.
That is the cost of a central guard keyed on a parameter name: it covers
everything that follows the convention and silently misses everything
that does not.
Verified live as an admin:
create team in own workspace -> 200
create team in another workspace -> 403
delete another workspace's team via
own org_id in the path -> 403, target team untouched
165 tests pass.
jira linking fix
The previous commit (preserve Jira token encryption keys at startup) added a good safety check -- refuse to start rather than silently regenerate keys over a present-but-corrupt config.ini, which would orphan already-encrypted provider tokens -- but in doing so removed the *only* mechanism that ever populated SECRET_PUBLIC_KEY/ SECRET_PRIVATE_KEY as environment variables for the frontend process. web-server/src/utils/auth-supplementary.ts's enc()/dec() (used by every provider link -- Jira, GitHub, GitLab) reads these via process.env, not from config.ini directly, unlike the Python backend. With no export step at all, that lookup is undefined on every boot, not just subsequent ones, so linking any provider fails outright before the request ever reaches the provider's API. This restores the export -- directly into the current shell via `export "$key=$value"` rather than the old ~/.bashrc round-trip, which is simpler and avoids the file-based indirection -- after the corruption check, so both concerns are addressed: never silently regenerate/corrupt keys, and the web-server actually receives the ones already on disk. Verified empirically (not just by re-reading the script) that a plain `KEY=value` line only becomes a local shell variable and is invisible to a child process unless `export`-ed in the same shell before that child is spawned.
fix: restore env-var export for the Node web-server's encryption keys
…pelines Two sequential PRs from one design: code provider first (lead time, LOC, contributor filter, revert incidents), Pipelines as a deployment source second. Cloud v2 API, Atlassian API token via Basic auth, server-side validation, 429-as-pause with bookmark resume. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Seven tasks: v2 client, ETL handler, activity/diffstat/429 contract, revert detection + registration, BFF token check + repo listing, the modal, and provider-isolation regression with a live-verification gate. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Basic auth (email, Atlassian API token) on the session -- never in a header string or URL. Pagination follows Bitbucket's next-link scheme. The PR listing names every state explicitly: without it the API returns only open PRs and every merged PR silently vanishes from lead time. 429 raises BitbucketRateLimitExceeded carrying Retry-After; the ETL handler owns pause-and-resume policy, since only it knows what has been safely stored. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Mirrors GitlabETLHandler against the CodeProviderETLHandler contract.
DECLINED and SUPERSEDED fold into CLOSED; an unknown state skips that
PR, never the batch. state_changed_at for merged PRs is updated_on --
Bitbucket has no merged_at anywhere in the PR object.
Author is the nickname with uuid fallback, correcting the spec: the
contributor dropdown lists author strings verbatim and the schema has
no display indirection, so a stored uuid would surface as '{a1b2...}'
in the UI. The uuid stays in data for a future identity layer.
Repo listing is one workspace call with uuid match-back rather than a
call per repo -- N repos cost 1 request against a ~1,000/hr ceiling.
Reviewers: create_pr_metrics rebuilds them from review events on every
non-open PR (shared analytics contract, same as GitHub/GitLab); the
participants list serves OPEN PRs. Tests pin both paths.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The handler behaviours landed with Task 2's mirror; these tests pin them and were mutation-checked to prove they bite: turning the 429 break into continue fails three tests, and returning zeros from a failed diffstat instead of omitting code_stats fails one. Event states are asserted via PullRequestEventState values -- the analytics layer compares data['state'] against the lowercase enum values, so literal-case assertions are the contract, not cosmetics. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Detection keys on Bitbucket's own revert branch convention, revert-pr-<number> -- a structured link to the original PR, matched in both sync directions like GitLab's revert-<hash> handler. The spec's title-prefix heuristic was dropped as strictly inferior, not weakened: a title names no target, and a mapping without both ends is useless to CFR. Spec corrected. A factory test pins every CodeProvider value to a CodeETLFactory branch -- an enum value without one fails at sync time as a NotImplementedError in a scheduler log nobody reads. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The token check runs in the BFF because api.bitbucket.org sends no CORS headers for Basic auth from foreign origins -- a browser-direct check dies in preflight. The reply is a boolean and a nickname; the token is never logged, persisted, or echoed. Repo listing threads Bitbucket's opaque next-page URL through the shared cursor field, and the adapter lives in an import-light util so its test does not drag Endpoint -> next-auth's ESM build into jest -- the same wall benchmarks.ts was written around. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Email + API token modal validated through the BFF check; the email rides to provider_meta, which the sync factory reads back as the Basic auth username -- the modal test pins that exact linkProvider shape. The integration card is generated from the Gitlab card with provider identifiers swapped; a bitbucket.svg already shipped in mocks/icons and the ambient IntegrationsMap already carried the bitbucket key upstream. Also fixes the gap the plan missed: CODE_INTEGRATION_BUCKET decides which orgs the scheduler syncs at all, and it listed only GitHub and GitLab -- a linked Bitbucket org would never sync, with no error anywhere. Same defect class the Jenkins integration shipped. A test now pins every CodeProvider value into the bucket, alongside Task 4's factory pin. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Backend: an org with only GitHub linked still gets exactly ['github'] from the scheduler's provider lookup -- the bucket gaining a third entry changes no existing org's sync plan. Frontend: the card reads integrations.bitbucket only; a workspace with GitHub and GitLab linked sees Bitbucket unlinked, inheriting nothing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The first real linking attempt failed with the catch-all message. Two causes were indistinguishable: wrong credentials, and a scoped Atlassian token created without the account read scope -- which works against repositories but fails /2.0/user, the exact call the sync's validity check makes. The check endpoint now probes /2.0/workspaces on failure to tell them apart, and the modal names the missing scope. Both fields are trimmed at submission: a token copied from Atlassian's UI often carries a trailing newline, which corrupts the Basic auth pair into a 401 that reads exactly like a wrong token. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… autofill GET /2.0/workspaces returns 410 'CHANGE-2770 - Functionality has been deprecated'. Every fixture test passed against an endpoint that no longer exists; only the live gate caught it. get_workspaces now uses /2.0/user/permissions/workspaces, with a test pinning the URL. Note: scoped API tokens cannot enumerate workspaces at all (404 there too) -- workspace-addressed endpoints work fine, so sync is unaffected; the repo-picker UI will need a workspace-slug input as a follow-up. Both modal fields get autoComplete='new-password': Chrome's password manager silently replaced pasted values with saved logins during live testing -- the dots looked right and the pair failed as 'invalid credentials'. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
C1 (security): the Bitbucket pagination cursor is a client-supplied URL fetched server-side with the org's Basic auth header -- unvalidated, it was an SSRF exfiltrating the Atlassian token to any host a workspace member named. Cursors must now be prefix-anchored to Bitbucket's API. C2: Number(idempotency_key) turned Bitbucket's brace-uuid keys into NaN in the team edit UI; the next save persisted 'NaN', silently killing that repo's sync and making it un-removable. Non-numeric keys now pass through verbatim. I1: the missing-scope diagnostic probed /2.0/workspaces -- the endpoint this branch itself found dead -- making the reason unreachable. A 403 from /2.0/user is the real scope signal. I2: token-check's fetch is wrapped so a network error degrades cleanly instead of reaching the global handler, which logs the whole request, token included. I3: a 429 during check_pat surfaced as 'token is invalid, revoked or expired' at sync start -- in exactly the resume window a 429 pause creates. It now raises the rate-limit error it is. Minors: approval event keys use the stable account uuid (nickname renames duplicated events on re-sync); OPEN PRs get state_changed_at None matching GitHub; a re-sync whose diffstat fails keeps previously stored code_stats instead of erasing them; canonical workspace slug for parent; Error cause bag; spec staleness. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Bitbucket Cloud as a code provider (phase 1)
A team save 500'd for any repo another workspace already tracked -- repo-specific, deterministic, and permanent. Root cause: OrgRepo carried two unique constraints without org_id (idempotency_key alone, and org_name+name+provider), and the repo lookup in update_org_repos was global, so the second workspace found the first workspace's row and hit upstream's cross-org 'Data integrity error' raise. The lookup is now org-scoped, the unreachable raise is gone, and the migration rescopes both constraints per org -- strictly weaker, so existing data needs no fix-up. Live-verified locally: the same GitHub repo saved into a second org cleanly, one row per workspace. The second constraint was caught by the live repro, not code reading: with only the idempotency constraint scoped, the insert died on one_repo_per_provider instead. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
signOut({ callbackUrl: '/login' }) resolves the relative URL server-side
against NEXTAUTH_URL, which on the server is not the public domain. The
redirect now happens client-side against the actual origin, after
signOut({ redirect: false }) clears the session.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Fix cross-workspace repo collision: scope OrgRepo uniqueness per org
Mirrors the setup already running on hrms, qa-process-automation and
be-automation, adapted to this repo.
Placed between Verify Environment and Build, so the gate can actually stop a
release -- this pipeline deploys, unlike the QC automation jobs where the scan
runs after the work. Verify Environment still runs first so a missing .env
variable fails fast and cheaply, before a scan is spent, keeping the existing
"fail before anything is torn down" ordering intact.
- SonarQube Analysis: runs the sonar-scanner CLI via the official
sonarsource/sonar-scanner-cli image inside withSonarQubeEnv('MySonarQube').
The agent has Docker but no sonar-scanner on PATH and no SonarQube Scanner
tool installation, so the image avoids adding global tool config.
sonar.working.directory is redirected into the bind-mounted workspace: the
image's baked-in /tmp/.scannerwork is owned by uid 1000 and unwritable under
-u, and the override also lands report-task.txt where waitForQualityGate
looks for it.
- Quality Gate: waitForQualityGate(abortPipeline: true) inside a 5 minute
timeout, so a missed webhook cannot hold the deploy hostage.
- Fetch Sonar Issues / Publish Issue Report: paginates api/issues/search and
renders the result on the build page via warnings-ng. Both wrapped in
catchError(buildResult: 'UNSTABLE') so reporting cannot fail a deploy that
already passed the gate. The merged JSON keeps the top-level total/p/ps
fields, without which the warnings-ng parser fails format detection and
silently reports zero issues.
sonar-project.properties is new. This is a polyglot monorepo (282 Python, 266
TS, 188 TSX), so sources are listed explicitly to keep media_files/,
database-docker/ and docs/ out. backend/analytics_server/tests and
cli/source/__tests__ sit inside source roots, so they are excluded from main
and declared as tests instead -- without that the scan fails outright with
"file can't be indexed twice".
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ci: add SonarQube analysis, quality gate and issue report
…elated fixes Implements docs/JIRA_MULTI_ACCOUNT_PLAN.md end to end: - Task 1-2: JiraConnection + OrgProjectConnection schema and repo/service layer (create/list/get/delete/set-default, encrypted tokens, delete blocked while referenced, default-switch atomicity). - Task 3: Flask + Next.js API endpoints for managing connections, proxied through the backend so business rules live in one place. - Task 4: connection-aware sync -- JiraETLHandler loops JiraConnection rows (falling back to the legacy Integration row when none exist), scoped ticket idempotency keys, fixed get_org_providers so a connection-only org actually syncs. - Task 5: PR<->ticket matching scoped by connection for the rare colliding-key case, without changing the default org-wide matching behavior for every ordinary org. - Task 6: connections management UI folded into the existing Jira card (not a second card), site-URL normalization (a pasted "https://x.atlassian.net/" was being stored verbatim and building an unreachable URL at search/sync time), and a connection picker for per-team Jira project search/save (jira_project_search.ts, team_projects.ts), closing the OrgProjectConnection write-side gap from Task 4. Also, found while verifying against a 15-scenario Jira<->PR<->deployment spec: - PR<->ticket matching now scans only the PR title (previously also scanned branch name and description) -- the PR title is the sole authoritative source per that spec; branch/description/commit are never used as a fallback. - New TeamRepoProjectMapping: an explicit, informational repo<->Jira- project pairing per team (never affects matching/sync/metrics). - Team creation no longer hard-requires a Git repo -- an opt-in "Jira-only, no Git repo" checkbox lets an org with only Jira create a team, without changing the default repo-required flow for anyone who doesn't check it. - DoraMetricsBody's empty-state check no longer ignores Jira ticket- cycle-time data -- a repo-less team with real ticket data was always falling into "configure team repos" instead of showing it. - Fixed a real, live bug: teams/v2.ts's default code-provider list omitted Bitbucket in two places, undercounting a team's repos on the team list and leaving its edit-form repo picker empty even when a Bitbucket repo was genuinely linked and its metrics were computing correctly. Backend: 567 tests passing, flake8/black clean. Frontend: tsc --noEmit clean; new/touched test files verified individually (this environment's memory constraints made a single combined jest run unreliable, noted in the plan doc). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
|
|
Important Review skippedToo many files! This PR contains 387 files, which is 237 over the limit of 150. To get a review, reduce the PR to 150 files or fewer by splitting it into smaller PRs or changing its base branch. Upgrade to a paid plan to raise the limit. Usage-priced reviews support at most 300 files. ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (387)
You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Linked Issue(s)
Acceptance Criteria fulfillment
Proposed changes (including videos or screenshots)
Further comments