Repository navigation
fix(jira): tolerate malformed nested Jira status fields - #25656
Conversation
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThe Jira connection status parser now validates and normalizes viewer, site, and optional status fields. It returns a disconnected status for invalid top-level input or a non-boolean Priority: ⬇️ Low Merge Risk: 🔵 Low · up to If Jira returns a malformed site that was selected, the issue list could appear empty until the user reselects a site. Reconciling the selected IDs after filtering is a small fix and worth making before merge, but the impact is limited. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change improves malformed-response handling without changing Jira permissions or stored credentials. Remaining uncertainty concerns inconsistent replies from older connected hosts. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
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 |
There was a problem hiding this comment.
ℹ️ No critical issues — one minor test-coverage gap.
Reviewed changes
parseJiraConnectionStatussanitizes nested fields instead of rejecting the whole reply. A connected status stays connected: an invalidviewerbecomesnull, malformed sites are dropped individually,activeSiteId/selectedSiteIdare kept only as string-or-null, andcredentialError/credentialProtectiononly when they match their expected types.- New helpers (
parseJiraViewer,parseJiraSite,isOptionalSiteId,isOptionalCredentialProtection) validate each nested value, dropping unknownauthTypeand future enum values rather than storing them. - Tests add a malformed-but-connected reply and a site with an unknown
authType.
I traced every reader of jiraStatus (jira-integration-card.tsx, use-task-page-repo-selection.ts, use-task-page-store-bindings.ts, use-integration-connection-status.ts, jira-read-coordination.ts); none dereferences a dropped field unsafely, and src/main/jira/site-credential-store.ts already requires the same site string fields, so no real persisted site is newly dropped. Focused vitest passes (9 tests).
ℹ️ Nitpicks
- The two inputs the base parser treated as disconnected — a non-object
viewer(e.g.viewer: 'me') and a non-arraysites(e.g.sites: {}) — lost theirit.eachrows with no replacement. These are precisely the shapes this PR now tolerates, so a case asserting{ connected: true, viewer: null }(andsitesomitted) for each would pin the behavior change.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
Allowed auth types and credential protections are coverage records over JiraAuthType and SecretAtRestProtection, and the parsed status must list every JiraConnectionStatus key, so a union or field change in the shared types fails tsc instead of being silently dropped by this parser. Adds a populated multi-site round-trip fixture and keeps connected statuses with a malformed viewer or sites value connected.
Site and viewer parsing now lists every JiraSite and JiraViewer key, like the top-level status, so a new optional field fails tsc instead of being dropped.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
cfa017fd-b7a5-4da2-a10f-85c33c79a857
📒 Files selected for processing (2)
src/renderer/src/runtime/runtime-jira-connection-status.test.tssrc/renderer/src/runtime/runtime-jira-connection-status.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
| activeSiteId: parseOptionalSiteId(value.activeSiteId), | ||
| selectedSiteId: parseOptionalSiteId(value.selectedSiteId), |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Inspect Jira status consumers for handling of IDs absent from the parsed sites.
fd -i 'jira' src/renderer/src/store/slices src/renderer/src/runtime \
--type f -e ts -e tsx |
while IFS= read -r file; do
rg -n -C 4 'activeSiteId|selectedSiteId' "$file" || true
doneRepository: stablyai/orca
Length of output: 12166
🏁 Script executed:
printf '%s\n' '--- parser ---'
nl -ba src/renderer/src/runtime/runtime-jira-connection-status.ts | sed -n '1,125p'
printf '%s\n' '--- bound parser/status references ---'
rg -n -F -- 'parseJiraConnectionStatus' src/renderer/src
printf '%s\n' '--- selection and site resolution references ---'
rg -n -F -e 'getSelectedJiraSiteId' -e 'activeSiteId' -e 'selectedSiteId' src/renderer/src/store/slices src/renderer/src/runtime || test "$?" -eq 1Repository: stablyai/orca
Length of output: 11160
🏁 Script executed:
printf '%s\n' '--- jira connection actions ---'
nl -ba src/renderer/src/store/slices/jira-connection-actions.ts | sed -n '1,230p'
printf '%s\n' '--- jira collection read actions ---'
nl -ba src/renderer/src/store/slices/jira-collection-read-actions.ts | sed -n '1,230p'
printf '%s\n' '--- jira read coordination ---'
nl -ba src/renderer/src/store/slices/jira-read-coordination.ts | sed -n '1,190p'
printf '%s\n' '--- runtime jira client ---'
nl -ba src/renderer/src/runtime/runtime-jira-client.ts | sed -n '1,125p'
printf '%s\n' '--- runtime jira summary client ---'
nl -ba src/renderer/src/runtime/runtime-jira-summary-client.ts | sed -n '1,80p'Repository: stablyai/orca
Length of output: 31722
🏁 Script executed:
printf '%s\n' '--- remaining jira read coordination ---'
nl -ba src/renderer/src/store/slices/jira-read-coordination.ts | sed -n '180,360p'
printf '%s\n' '--- jira client request implementations ---'
nl -ba src/renderer/src/runtime/runtime-jira-client.ts | sed -n '115,300p'
printf '%s\n' '--- repository siteId consumers outside renderer ---'
rg -n -F -e 'siteId' -e 'jira.search' -e 'jira.list' -e 'jira.status' src | rg 'jira|Jira|siteId' | head -240Repository: stablyai/orca
Length of output: 31551
🏁 Script executed:
printf '%s\n' '--- main jira client site selection ---'
nl -ba src/main/jira/client.ts | sed -n '130,225p'
printf '%s\n' '--- main jira issue search ---'
nl -ba src/main/jira/jira-issue-search.ts | sed -n '1,125p'
printf '%s\n' '--- jira shared types ---'
rg -n -C 8 'interface JiraConnectionStatus|type JiraConnectionStatus|JiraSiteSelection|interface JiraSite|type JiraSite' src/shared/jira-types.ts
printf '%s\n' '--- site selection tests and status tests ---'
rg -n -C 8 'missing|unknown|invalid|selectedSiteId|activeSiteId|getClients|site failure|siteId' src/main/jira/client.test.ts src/main/jira/issues.test.ts src/main/jira/jira-issue-search.test.ts 2>/dev/null || trueRepository: stablyai/orca
Length of output: 41679
🏁 Script executed:
rg -n -C 12 'export function getClients|function getClients|export function getStatus|function getStatus' src/main/jira/client.ts
nl -ba src/main/jira/client.ts | sed -n '1,135p'Repository: stablyai/orca
Length of output: 7776
Repair Jira site IDs after filtering sites.
When sites is an array, retain activeSiteId and selectedSiteId only when they refer to a parsed site. Preserve the all selection. Otherwise, select a remaining site or clear the ID.
The store saves the parsed status without this reconciliation. A stale ID reaches getClients, which can find no client, and Jira issue reads then return an empty list without making a request.
Suggested fix
+function normalizeSiteId(
+ value: unknown,
+ sites: JiraSite[] | undefined,
+ allowAll = false
+): string | null | undefined {
+ const siteId = parseOptionalSiteId(value)
+ if (sites === undefined || siteId === undefined || siteId === null) return siteId
+ if (allowAll && siteId === 'all') return siteId
+ return sites.some((site) => site.id === siteId) ? siteId : sites[0]?.id ?? null
+}
+
export function parseJiraConnectionStatus(value: unknown): JiraConnectionStatus {
if (!isRecord(value) || typeof value.connected !== 'boolean') {
return { connected: false, viewer: null }
}
+ const sites = parseJiraSites(value.sites)
const status: EveryKey<JiraConnectionStatus> = {
connected: value.connected,
viewer: parseJiraViewer(value.viewer),
- sites: parseJiraSites(value.sites),
- activeSiteId: parseOptionalSiteId(value.activeSiteId),
- selectedSiteId: parseOptionalSiteId(value.selectedSiteId),
+ sites,
+ activeSiteId: normalizeSiteId(value.activeSiteId, sites),
+ selectedSiteId: normalizeSiteId(value.selectedSiteId, sites, true),There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Incremental review of the two commits pushed since the prior pullfrog review (afe53cc).
- Tied
authTypeandcredentialProtectionvalidation to the sharedJiraAuthType/SecretAtRestProtectionunions viasatisfiescoverage records, so adding or removing a union arm fails the typecheck. - Made the built status, each site, and the viewer exhaustive with
EveryKey<T>, so a field added to those shared types fails the typecheck until the parser names it. - Replaced the remaining spread-based omission of optional fields with explicit
undefinedvalues, keeping the sanitize-or-drop behavior otherwise unchanged. - Added tests for populated multi-site round-trips, the previously uncovered non-object
viewer/ non-arraysitesshapes, and a reply carrying malformed nested values.
I verified the parser tests (11 passed) and tc:web (clean), traced the readers of jiraStatus (jira-integration-card.tsx, use-jira-url-source.ts, jira-read-coordination.ts, and the task-page bindings), and confirmed that the switch from omitted optional keys to explicit undefined does not trip hasJiraStatusChanged into repeat updates: parsed-to-parsed comparisons use ?., ?? [],/?? null and shallow, and the status is held only in memory.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
…tus-parse-followup
Review and QA summaryThe problem. #25579 stopped the paired web client crashing with "Orca web hit a renderer error". It reads a missing or malformed Jira status reply as "disconnected". A review of #25579 found a gap: the check trusted everything inside the What changes for users. A connected Jira status with one bad site now stays connected and shows every valid site; only the bad site is left out. A malformed signed-in user shows as no user, and the connection is kept. Statuses that real Orca hosts send come through unchanged. Fixed during review:
Deferred:
Verified:
Not verified:
|
…tus-parse-followup

ELI5
When Orca asks for your Jira connection, the reply can carry one odd detail: an empty slot in the list of sites, say, or a value from a newer Orca. A connected user should still see Jira as connected with every good site. The bad detail should be ignored, not crash the app or make Jira look disconnected.
What Changed
The problem. #25579 stopped the paired web client crashing with "Orca web hit a renderer error". It does this by checking each Jira status reply before the app stores it. A missing or malformed reply now reads as "disconnected". A review of #25579 found a gap: the check accepted any list of sites and trusted everything inside it. So a reply with one malformed site (for example
null) still reached screens that readsite.id, and those screens could crash.What you see now.
Mechanism.
parseJiraConnectionStatus(src/renderer/src/runtime/runtime-jira-connection-status.ts) used to check a few top-level fields and then assert the whole reply was the right type. It now builds the status, each site and the signed-in user field by field, with no type assertion:JiraAuthTypeandSecretAtRestProtectiontypes.So a value or field added to those types later fails the typecheck until the parser handles it, instead of being silently dropped.
Why
The check sits at the one place every Jira status passes through: local desktop replies, replies from remote Orca servers, site selection and the summary read. Validating there protects every screen at once. Hosts and clients of different versions are normal for remote servers, so the parser tolerates one bad detail instead of rejecting the whole reply. An earlier revision of this PR read any malformed nested field as "disconnected". That could hide a real connection, so it was replaced.
Tying the parser to the shared types fixes a problem a hand-written checker usually has: it falls out of date. The
credentialProtectionfield was added this way recently, and an untied parser would have dropped it.Related, not in this PR. Jira has never been wired into the paired web client's bridge to its server. That is why the web client gets a missing reply and shows Jira as disconnected. Wiring it would turn Jira on in the web client, so it is a separate change.
Linked Issue
Follow-up to #25579.
Author: @BrennanKB5
Visual Proof
Checked on macOS at 22638f8, using a hidden Electron build with an isolated profile and stub agents only. No real Jira account was used.
Desktop, Jira status reply with one malformed site. The reply listed two valid sites plus
nulland{ id: 7 }. Jira stays Connected and shows exactly the two valid sites:On
origin/main, the same reply keeps thenulland{ id: 7 }entries in the stored sites. This was checked by running main's parser in Node, not by rendering it.Desktop with no Jira configured. Jira shows Not connected and nothing crashes:
Paired web client. It renders normally, with no "Orca web hit a renderer error", and Jira shows Not connected:
Testing
node_modules/.bin/vitest run --config config/vitest.config.ts --exclude '**/*real-cli*' --exclude '**/*real-binary*'on the parser test, every test that imports the parser or the Jira runtime clients, and all Jira store tests. 8 files, 79 passed.tc-gate pnpm tc:webpassed.pnpm run check:code-quality:changed, oxlint and oxfmt are clean.Review
Reviewed in several rounds against real producers, current and older. Every Orca host since Jira support was added sends sites whose fields are all strings, so no real site or user is dropped. The renderer never reads a site's auth type from the status. The status is held only in memory and only a site id is sent back to the host. No mobile-facing surface is touched.
Agent skill upstream boundary
Checklist