Skip to content

fix(jira): tolerate malformed nested Jira status fields - #25656

Merged
brennanb2025 merged 6 commits into
mainfrom
brennanb2025/jira-status-parse-followup
Oct 6, 2026
Merged

brennanb2025 merged 6 commits into
mainfrom
brennanb2025/jira-status-parse-followup

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​117 $\color{#cf222e}{\Huge{\mathbf{−}}}$​3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​114
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​90 $\color{#cf222e}{\Huge{\mathbf{−}}}$​9 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​81

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 read site.id, and those screens could crash.

What you see now.

  • A connected Jira status with one malformed site stays connected. You see every valid site; only the malformed one is left out. Before, that reply could crash the screen that lists sites.
  • A malformed signed-in user is shown as no user. The connection itself stays as reported.
  • An unfamiliar optional value, such as an auth type from a newer Orca version, is left out instead of being passed along unchecked.
  • A missing reply still reads as disconnected, exactly as after fix(jira): stop the paired web client crashing on a missing Jira status #25579. This is what the paired web client gets today.
  • Statuses that real Orca hosts send come through unchanged. That includes self-hosted Jira sites with an empty email or account id, the "all sites" selection, and credential warnings.

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:

  • The allowed auth types and credential-protection values are tied to the shared JiraAuthType and SecretAtRestProtection types.
  • The result for the status, each site and the user must list every field of the shared type.

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 credentialProtection field 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 null and { id: 7 }. Jira stays Connected and shows exactly the two valid sites:

row2-desktop-malformed-site

On origin/main, the same reply keeps the null and { 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:

row1-desktop-no-jira

Paired web client. It renders normally, with no "Orca web hit a renderer error", and Jira shows Not connected:

row3-web-client
row3-web-client-settings

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:web passed.
  • pnpm run check:code-quality:changed, oxlint and oxfmt are clean.
  • Typecheck ablation, on the parser and its shared types compiled alone. Each of these fails the typecheck with the new parser; the previous parser compiled and silently dropped them:
    • adding an auth type, or removing one;
    • adding a credential-protection value;
    • adding a new optional field to the status, a site or the signed-in user.

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

  • Not applicable.

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • Visual proof attached
  • Self-reviewed for correctness, security, and performance
  • Cross-platform and SSH/remote impact considered: no platform-specific code; replies from remote servers of other versions are the main case this handles.

@brennanb2025
brennanb2025 marked this pull request as ready for review October 5, 2026 19:20
@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 87302f63-71ba-4e79-bbf1-7d628cd49038
📥 Commits

Reviewing files that changed from the base of the PR and between bebf771 and 115e453.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The 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 connected value. For connected statuses, it uses null for an invalid viewer, filters invalid sites, and retains optional fields only when their values are supported. Tests cover populated statuses, malformed nested values, and sites with unknown authentication types.

Priority: ⬇️ Low

Merge Risk: 🔵 Low · up to 22638

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 Review

Security architecture risk: 🔵 Low · up to 22638

The change improves malformed-response handling without changing Jira permissions or stored credentials. Remaining uncertainty concerns inconsistent replies from older connected hosts.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — A malformed reply gains greater influence over connected presentation and subsequent request attempts than under whole-status rejection. In the inspected implementation, this does not expand credential-backed access beyond the selected runtime's configured Jira sites.

Trust Boundaries and Controls

  • observed — The parser validates reply shape but does not authenticate the reported identity or connection. Backend site and token lookup remains the control separating renderer-supplied selection from credential-backed Jira operations.

Resilience and Maintainability Implications

  • observed — The inspected RPC implementation delegates disconnect and status to the same backend. Disconnect removes the targeted site entries; status derives connected from remaining configured sites with stored tokens. Keeping other sites connected after a site-specific disconnect is therefore intentional, not a failed global logout.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 12.50% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 8 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the Jira status parsing change and its tolerance of malformed nested fields.
Description check ✅ Passed The description covers the change, rationale, testing, visual proof, review, and checklist. It references #25579 as a follow-up, but does not provide a clear link to an issue as the template requests.
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No critical issues — one minor test-coverage gap.

Reviewed changes

  • parseJiraConnectionStatus sanitizes nested fields instead of rejecting the whole reply. A connected status stays connected: an invalid viewer becomes null, malformed sites are dropped individually, activeSiteId/selectedSiteId are kept only as string-or-null, and credentialError/credentialProtection only when they match their expected types.
  • New helpers (parseJiraViewer, parseJiraSite, isOptionalSiteId, isOptionalCredentialProtection) validate each nested value, dropping unknown authType and 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-array sites (e.g. sites: {}) — lost their it.each rows with no replacement. These are precisely the shapes this PR now tolerates, so a case asserting { connected: true, viewer: null } (and sites omitted) for each would pin the behavior change.

Pullfrog  | Fix it ➔ | View workflow run | Using 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.
@brennanb2025 brennanb2025 changed the title fix(jira): reject malformed nested status replies fix(jira): tolerate malformed nested Jira status fields Oct 5, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cfa017fd-b7a5-4da2-a10f-85c33c79a857
📥 Commits

Reviewing files that changed from the base of the PR and between afe53cc and 22638f8.

📒 Files selected for processing (2)
  • src/renderer/src/runtime/runtime-jira-connection-status.test.ts
  • src/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.

Comment on lines +92 to +93
activeSiteId: parseOptionalSiteId(value.activeSiteId),
selectedSiteId: parseOptionalSiteId(value.selectedSiteId),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🗄️ 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
done

Repository: 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 1

Repository: 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 -240

Repository: 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 || true

Repository: 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),

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

Incremental review of the two commits pushed since the prior pullfrog review (afe53cc).

  • Tied authType and credentialProtection validation to the shared JiraAuthType / SecretAtRestProtection unions via satisfies coverage 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 undefined values, keeping the sanitize-or-drop behavior otherwise unchanged.
  • Added tests for populated multi-site round-trips, the previously uncovered non-object viewer / non-array sites shapes, 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.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@brennanb2025

Copy link
Copy Markdown
Contributor Author

Review and QA summary

The 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 sites list. A reply with one malformed site (for example null) could still reach screens that read site.id and crash them. The first version of this PR overcorrected and read any malformed nested field as "disconnected", which could hide a real connection.

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:

  • Title and body. The title said "reject", but the code tolerates bad fields. Both are rewritten.
  • Allowed values tied to the shared types. The allowed auth types and credential-protection values were hand-copied. A new value would have been silently stripped with the typecheck still green. They are now tied to JiraAuthType and SecretAtRestProtection.
  • New fields caught by the typecheck. The parser built the status, each site and the signed-in user from hand-picked fields, so a field added later would have been silently dropped. Each must now list every field of its shared type, so a new field fails the typecheck. A scratch-compile ablation confirmed this: the new parser fails, and the previous one compiled and dropped the field.
  • Tests. Added a test that a fully populated real status passes through unchanged: a self-hosted site with an empty email and account id, the "all sites" selection, and credential warnings. Also added "stays connected" tests for a malformed viewer and a non-list sites.

Deferred:

  • Jira in the paired web client. The web client's bridge to its server never had a Jira entry, which is the underlying reason the web client gets a missing reply. Jira has therefore never worked there. Wiring it in turns Jira on in the web client, so it is tracked separately in STA-5712. The work so far is on the branch brennanb2025/web-client-jira-namespace-wip, with no PR yet.
  • Undefined vs. missing fields (minor). Optional fields that are absent now come back as undefined values rather than missing keys. Only one case can tell the difference: right after Connect, on a host that sends no sites list. That case gets one extra status update. Current hosts always send sites.
  • A test pinning the exact field layout. Not needed today, because nothing in Orca reads the layout.

Verified:

  • Unit tests. 8 named test files, 79 passed. They cover the parser, every test that imports it or the Jira runtime clients, and all Jira store tests.
  • Typecheck and lint. tc-gate pnpm tc:web passed, and the changed-code quality gate, oxlint and oxfmt are clean.
  • Release-readiness checklist. It ran on the final diff and found no P0, P1 or P2 issues: no remote-version, crash, persistence, mobile or cross-platform impact.
  • Electron QA on macOS. It ran a hidden build with an isolated profile and stub agents, with no real Jira account. Screenshots are in the PR body.
    • Desktop with no Jira: shows Not connected, no crash.
    • Desktop status reply with two valid sites plus null and { id: 7 }: Jira stays Connected with exactly the two valid sites.
    • Paired web client: renders normally with no renderer error, and Jira shows Not connected.
    • tests/e2e/paired-startup-exec-readiness.spec.ts:122 headless: passed.

Not verified:

  • No real Jira account, and no rendered run of origin/main for comparison. Main's parser was run in Node and keeps the bad entries.
  • The malformed-signed-in-user and unknown-value cases are covered by unit tests only, not in the UI.
  • CI on the current head is red, but not because of this PR. Lint fails on src/main/native-chat/agent-session-journal/journal-submission-positions.test.ts, which imports codexProviderHandle twice on current main (lines 10 and 22). That file is untouched here. The unit-test jobs did not run behind that failure. Once main is fixed, a re-run is needed.

@brennanb2025
brennanb2025 merged commit 842c6c6 into main Oct 6, 2026
30 checks passed
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.

1 participant