Skip to content

Fix Jira Composio subdomain authorization#1733

Merged
senamakel merged 1 commit into
tinyhumansai:mainfrom
aqilaziz:fix-jira-atlassian-subdomain
May 15, 2026
Merged

Fix Jira Composio subdomain authorization#1733
senamakel merged 1 commit into
tinyhumansai:mainfrom
aqilaziz:fix-jira-atlassian-subdomain

Conversation

@aqilaziz
Copy link
Copy Markdown
Contributor

@aqilaziz aqilaziz commented May 14, 2026

Summary

  • prompt Jira users for their Atlassian subdomain before starting Composio authorization
  • normalize pasted *.atlassian.net URLs and send extra_params.subdomain to openhuman.composio_authorize
  • map Composio ConnectedAccount_MissingRequiredFields subdomain errors back to the inline Jira form instead of showing raw provider payloads

Closes #1702

Validation

  • pnpm --filter openhuman-app exec vitest run --config test/vitest.config.ts src/components/composio/ComposioConnectModal.test.tsx
  • pnpm typecheck
  • pnpm --filter openhuman-app exec prettier --check src/components/composio/ComposioConnectModal.tsx src/components/composio/ComposioConnectModal.test.tsx
  • pnpm --filter openhuman-app exec eslint src/components/composio/ComposioConnectModal.tsx src/components/composio/ComposioConnectModal.test.tsx --ext .ts,.tsx
  • python -m diff_cover.diff_cover_tool app/coverage/lcov.normalized.info --compare-branch=origin/main --fail-under=80 --markdown-report app/coverage/diff-coverage-jira.md (100% diff coverage)

Notes

  • Local git pre-push hooks are bypassed for the branch upload because this shallow Windows clone lacks app/src-tauri/vendor/tauri-cef/crates/tauri/Cargo.toml, which blocks pnpm rust:check. The change is limited to frontend TS/TSX files and the frontend checks above pass.

Summary by CodeRabbit

Release Notes

  • New Features
    • Added support for connecting Jira Cloud accounts with subdomain validation during the authentication flow.
    • Enhanced Atlassian integration with improved error messaging to guide users through required field entry.

Review Change Stack

@aqilaziz aqilaziz requested a review from a team May 14, 2026 12:07
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 14, 2026

📝 Walkthrough

Walkthrough

This PR adds required Atlassian subdomain collection and validation to the Jira integration flow. The modal now collects the subdomain input, normalizes it, validates it before authorization, and recovers from missing-subdomain backend errors with targeted UI feedback instead of exposing raw provider errors.

Changes

Jira Atlassian Subdomain Handling

Layer / File(s) Summary
Jira subdomain normalization and error detection
app/src/components/composio/ComposioConnectModal.tsx
Exports normalizeAtlassianSubdomain() to strip URL schemes, paths, ports, and .atlassian.net suffix, and isMissingAtlassianSubdomainError() to detect missing-subdomain errors via regex.
Component state, authorization handler, and subdomain input UI
app/src/components/composio/ComposioConnectModal.tsx
Adds atlassianSubdomain state and needsAtlassianSubdomain condition to conditionally show the subdomain input. Updates the connect handler to validate and normalize the subdomain before calling authorize (passing it as subdomain in extra params), and recovers from missing-subdomain errors by returning to idle and displaying a targeted remediation message. Renders a conditional subdomain input block with help text.
Test imports, fixtures, and subdomain validation coverage
app/src/components/composio/ComposioConnectModal.test.tsx
Updated imports to include subdomain helpers. Added jiraToolkit fixture and enhanced beforeEach to clear mocks and set default mock return values for authorize and openUrl. Added test cases verifying subdomain normalization, authorization param shapes, pre-auth gating, normalized subdomain transmission, and mapping of missing-subdomain backend errors to inline input feedback without exposing raw payloads.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 A Jira hop, so smooth and clean,
Subdomains now in between!
No more errors raw and bold—
Just friendly prompts, as stories told.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main change: fixing the Jira Composio subdomain authorization flow by collecting and validating the Atlassian subdomain.
Linked Issues check ✅ Passed The pull request comprehensively addresses all coding requirements from issue #1702: subdomain collection/validation, error detection and mapping, retry behavior, and test coverage with 100% diff coverage.
Out of Scope Changes check ✅ Passed All changes are scoped to Jira subdomain authorization: the component adds subdomain input/validation logic, exports helpers for error detection and normalization, and tests expand coverage for these features only.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint skipped: no ESLint configuration detected in root package.json. To enable, add eslint to devDependencies.


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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
app/src/components/composio/ComposioConnectModal.test.tsx (1)

169-189: ⚡ Quick win

Extend this scenario to verify the retry path.

This covers the inline remap, but the linked Jira bug is specifically about retrying authorization without restarting the flow. Please continue this test by clicking Connect Jira again after the inline error and asserting a second successful authorize('jira', { subdomain: 'acme' }) call.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/src/components/composio/ComposioConnectModal.test.tsx` around lines 169 -
189, Extend the test in ComposioConnectModal.test.tsx to exercise the retry
path: after the first mocked rejection of authorize and after asserting the
inline subdomain error is shown (using screen.findByText and the subdomain
input), mock vi.mocked(authorize) to resolve successfully for the next call,
trigger fireEvent.click on the "Connect Jira" button again and then assert that
authorize was called a second time with the expected arguments (e.g.,
authorize('jira', { subdomain: 'acme' })), and that the success path behaviors
(such as openUrl or modal close as appropriate) occurred; use the existing
jiraToolkit, ComposioConnectModal render, screen and fireEvent helpers to locate
and interact with the UI and ensure no duplicate error text remains.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/src/components/composio/ComposioConnectModal.tsx`:
- Around line 63-67: The Jira recovery matcher is only checking for
"ConnectedAccount_MissingRequiredFields" so it misses backend responses that
return numeric error code 612; update isMissingAtlassianSubdomainError to also
treat the numeric code by adding a check for "612" (e.g. include /\b612\b/i in
the first condition or combine with /ConnectedAccount_MissingRequiredFields/)
while keeping the existing subdomain check (/subdomain|Your Subdomain/i) so the
function returns true for either the textual code or the numeric 612 when
subdomain text is present.
- Around line 45-53: normalizeAtlassianSubdomain currently leaves query strings
or hash fragments on pasted URLs which breaks host validation; update
normalizeAtlassianSubdomain to also strip any query string or fragment after
trimming/protocol removal (e.g. remove everything from the first '?' or '#' like
using a regex replace for /[?#].*$/) before removing ports and the
ATLASSIAN_DOMAIN_SUFFIX, ensuring you still trim, lowercase, strip protocol,
strip path, strip port, then remove the ATLASSIAN_DOMAIN_SUFFIX if present.

---

Nitpick comments:
In `@app/src/components/composio/ComposioConnectModal.test.tsx`:
- Around line 169-189: Extend the test in ComposioConnectModal.test.tsx to
exercise the retry path: after the first mocked rejection of authorize and after
asserting the inline subdomain error is shown (using screen.findByText and the
subdomain input), mock vi.mocked(authorize) to resolve successfully for the next
call, trigger fireEvent.click on the "Connect Jira" button again and then assert
that authorize was called a second time with the expected arguments (e.g.,
authorize('jira', { subdomain: 'acme' })), and that the success path behaviors
(such as openUrl or modal close as appropriate) occurred; use the existing
jiraToolkit, ComposioConnectModal render, screen and fireEvent helpers to locate
and interact with the UI and ensure no duplicate error text remains.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 10c90b9c-574e-43fe-9fce-3ee1a8b24b8d

📥 Commits

Reviewing files that changed from the base of the PR and between 23fbaec and cd5f6cc.

📒 Files selected for processing (2)
  • app/src/components/composio/ComposioConnectModal.test.tsx
  • app/src/components/composio/ComposioConnectModal.tsx

Comment on lines +45 to +53
export function normalizeAtlassianSubdomain(value: string): string {
let normalized = value.trim().toLowerCase();
normalized = normalized.replace(/^https?:\/\//, '');
normalized = normalized.replace(/\/.*$/, '');
normalized = normalized.replace(/:\d+$/, '');
if (normalized.endsWith(ATLASSIAN_DOMAIN_SUFFIX)) {
normalized = normalized.slice(0, -ATLASSIAN_DOMAIN_SUFFIX.length);
}
return normalized;
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.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Strip query strings and hash fragments from pasted Atlassian URLs.

A pasted Jira URL like https://acme.atlassian.net?atlOrigin=... or ...#... currently normalizes to acme.atlassian.net?..., which then fails validation even though the host is valid. That makes some “paste the full URL” flows fail unnecessarily.

Suggested fix
 export function normalizeAtlassianSubdomain(value: string): string {
   let normalized = value.trim().toLowerCase();
   normalized = normalized.replace(/^https?:\/\//, '');
+  normalized = normalized.replace(/[?#].*$/, '');
   normalized = normalized.replace(/\/.*$/, '');
   normalized = normalized.replace(/:\d+$/, '');
   if (normalized.endsWith(ATLASSIAN_DOMAIN_SUFFIX)) {
     normalized = normalized.slice(0, -ATLASSIAN_DOMAIN_SUFFIX.length);
   }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/src/components/composio/ComposioConnectModal.tsx` around lines 45 - 53,
normalizeAtlassianSubdomain currently leaves query strings or hash fragments on
pasted URLs which breaks host validation; update normalizeAtlassianSubdomain to
also strip any query string or fragment after trimming/protocol removal (e.g.
remove everything from the first '?' or '#' like using a regex replace for
/[?#].*$/) before removing ports and the ATLASSIAN_DOMAIN_SUFFIX, ensuring you
still trim, lowercase, strip protocol, strip path, strip port, then remove the
ATLASSIAN_DOMAIN_SUFFIX if present.

Comment on lines +63 to +67
export function isMissingAtlassianSubdomainError(message: string): boolean {
return (
/ConnectedAccount_MissingRequiredFields/i.test(message) &&
/subdomain|Your Subdomain/i.test(message)
);
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.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Handle Composio error code 612 in the Jira-field matcher.

The Jira recovery path only recognizes ConnectedAccount_MissingRequiredFields, but the failure is also called out as code 612. If the backend returns only the numeric code, this branch will miss and the raw provider payload will still be surfaced through Authorization failed: ....

Suggested fix
 export function isMissingAtlassianSubdomainError(message: string): boolean {
   return (
-    /ConnectedAccount_MissingRequiredFields/i.test(message) &&
+    /(ConnectedAccount_MissingRequiredFields|(?:"code"|code)\D*612\b)/i.test(message) &&
     /subdomain|Your Subdomain/i.test(message)
   );
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/src/components/composio/ComposioConnectModal.tsx` around lines 63 - 67,
The Jira recovery matcher is only checking for
"ConnectedAccount_MissingRequiredFields" so it misses backend responses that
return numeric error code 612; update isMissingAtlassianSubdomainError to also
treat the numeric code by adding a check for "612" (e.g. include /\b612\b/i in
the first condition or combine with /ConnectedAccount_MissingRequiredFields/)
while keeping the existing subdomain check (/subdomain|Your Subdomain/i) so the
function returns true for either the textual code or the numeric 612 when
subdomain text is present.

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.

Jira connection fails because the Atlassian subdomain is missing

2 participants