Skip to content

MM-69474: normalize Jira base URL to prevent duplicate slash in posted links - #1336

Merged
nang2049 merged 2 commits into
masterfrom
MM-69474
Aug 12, 2026
Merged

MM-69474: normalize Jira base URL to prevent duplicate slash in posted links#1336
nang2049 merged 2 commits into
masterfrom
MM-69474

Conversation

@nang2049

@nang2049 nang2049 commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Every posted Jira link is built as GetJiraBaseURL() + "/browse/" + key so the base URL must not carry a trailing slash. The same gap existed beyond Cloud OAuth. GetJiraBaseURL()` has three implementations and none of them normalized.

  • Cloud OAuth: the reported bug
  • Server/DC: safe on a fresh install but v2-migrated instances bypass that
  • Cloud JWT: base URL comes from Atlassian's connect payload which in practice has no trailing slash, but nothing in our code guarantees it.

Fixes:

  • installCloudOAuthInstance now stores the normalized jiraURL instead of rawURL.
  • Added normalizeJiraBaseURL and routed all three GetJiraBaseURL() implementations through it, so instances already persisted with a bad URL are corrected without requiring a reinstall and every consumer is covered.
  • Pointed the Server/DC and Cloud JWT manage-apps/manage-webhooks URLs at GetJiraBaseURL() instead of GetURL().

Ticket Link

https://mattermost.atlassian.net/browse/MM-69474

Test Steps

  1. Install a Jira Cloud instance via the setup wizard, entering the URL with a trailing slash (https://your-instance.atlassian.net/).
  2. Run /jira create and create an issue, or attach a comment to an existing one.
  3. Confirm the posted link is https://your-instance.atlassian.net/browse/KEY-1 with a single slash and opens without a redirect.
  4. Repeat for a Jira Server/DC instance.

Change Impact: 🟡 Medium

Reasoning: The changes affect shared Jira URL handling across Cloud OAuth, Cloud JWT, and Server/DC integrations. Tests cover normalization and autolink paths, but management and webhook URLs also change.

Regression Risk: Medium. Existing instances and multiple integration paths are affected. The behavior change is limited to trailing-slash normalization.

QA Recommendation: Perform targeted manual QA for management links, webhooks, and autolinks across all supported integrations. Skipping manual QA has moderate risk.

Generated by CodeRabbitAI

@nang2049
nang2049 requested a review from a team as a code owner August 10, 2026 09:37
@nang2049 nang2049 added 2: Dev Review Requires review by a core committer 3: QA Review Requires review by a QA tester labels Aug 10, 2026
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: f1a066a3-9a86-4480-8d19-c72a93037c14

📥 Commits

Reviewing files that changed from the base of the PR and between 79af6c8 and 0acb462.

📒 Files selected for processing (4)
  • server/instance.go
  • server/instance_test.go
  • server/plugin.go
  • server/plugin_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • server/plugin.go
  • server/instance_test.go
  • server/instance.go

📝 Walkthrough

Walkthrough

The change adds trailing-slash normalization for Jira base URLs. Cloud and server management URLs, OAuth installation state, and autolink registration now use normalized URLs. Tests cover all supported instance types and project autolinks.

Changes

Jira base URL normalization

Layer / File(s) Summary
Normalize instance URLs
server/instance.go, server/instance_cloud.go, server/instance_cloud_oauth.go, server/instance_server.go
Adds shared trailing-slash normalization. Instance accessors and management URL builders use normalized Jira base URLs.
Update autolinks and validation
server/plugin.go, server/instance_test.go, server/plugin_test.go
Autolink registration uses GetJiraBaseURL(). Tests cover repeated trailing slashes, unchanged URLs, and project autolink URL templates.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels: 3: QA Review

Suggested reviewers: avasconcelos114, jgheithcock

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: normalizing Jira base URLs to prevent duplicate slashes in posted links.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch MM-69474

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 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 `@server/instance.go`:
- Around line 77-79: Update normalizeJiraBaseURL to remove all trailing slash
characters by using the appropriate right-trimming operation instead of
strings.TrimSuffix. Add a test covering a base URL with repeated trailing
slashes and verify the normalized result contains none.

In `@server/plugin.go`:
- Line 521: Update AddAutolinksForCloudInstance to pass ci.GetJiraBaseURL()
instead of the raw ci.BaseURL when creating Cloud JWT autolinks, and add
coverage verifying trailing-slash URLs are normalized without duplicate slashes.
🪄 Autofix

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: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 0cdefb51-9b05-4a6a-9476-ac0455faf00e

📥 Commits

Reviewing files that changed from the base of the PR and between 40d4d49 and 79af6c8.

📒 Files selected for processing (6)
  • server/instance.go
  • server/instance_cloud.go
  • server/instance_cloud_oauth.go
  • server/instance_server.go
  • server/instance_test.go
  • server/plugin.go

Comment thread server/instance.go
Comment thread server/plugin.go

@avasconcelos114 avasconcelos114 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM!

@ogi-m ogi-m left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM, working as expected!

@ogi-m ogi-m removed the 3: QA Review Requires review by a QA tester label Aug 12, 2026
@nang2049
nang2049 merged commit 2c7681f into master Aug 12, 2026
20 checks passed
@nang2049
nang2049 deleted the MM-69474 branch August 12, 2026 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2: Dev Review Requires review by a core committer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants