Skip to content

fix(openproject): preserve URL protocol in getOpenProjectSafeUrl#1354

Open
MacherelR wants to merge 2 commits into
matrix-org:mainfrom
MacherelR:fix/openproject_safe_url
Open

fix(openproject): preserve URL protocol in getOpenProjectSafeUrl#1354
MacherelR wants to merge 2 commits into
matrix-org:mainfrom
MacherelR:fix/openproject_safe_url

Conversation

@MacherelR

@MacherelR MacherelR commented Jun 24, 2026

Copy link
Copy Markdown

Related to #1353

Fix: OpenProject getOpenProjectSafeUrl hardcodes http:// causing HTTPS origin mismatch

Problem

When a user runs !hookshot openproject add https://op-instance/projects/<id> against an OpenProject instance served over HTTPS, the command always fails with:

Failed to handle command: Expected 'url' to match the origin 'https://op-instance'

Root cause

In src/Connections/SetupConnection.ts, getOpenProjectSafeUrl sanitises the user-provided URL and returns a normalised form to pass to provisionConnection. However, it hardcodes the http:// scheme regardless of the input:

return `http://${url.host}/projects/${projectId}`;

So a user input of https://op.example.com/projects/42 produces http://op.example.com/projects/42.

provisionConnection then calls validateOpenProjectConnectionState, which asserts:

if (parsedUrl.origin !== baseUrl.origin) {
    throw new ApiError(`Expected 'url' to match the origin '${baseUrl.origin}'`, ErrCode.BadValue);
}

Since config.openProject.baseURL.origin is https://op.example.com but the safe URL origin is http://op.example.com, the check always fails on HTTPS instances.

Testing

  • Deployed Hookshot 7.3.2 against a self-hosted OpenProject 17.5 instance over HTTPS
  • Without the fix: !hookshot openproject add https://op.example.com/projects/8 fails with origin mismatch
  • With the fix: command succeeds and the room is bridged correctly

@MacherelR MacherelR requested a review from a team as a code owner June 24, 2026 12:15
Comment thread src/Connections/SetupConnection.ts Outdated
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.

2 participants