Skip to content

Support for custom scheme in connection URI. - #723

Merged
rgrunber merged 1 commit into
che-incubator:mainfrom
rgrunber:custom-scheme
Jun 22, 2026
Merged

Support for custom scheme in connection URI.#723
rgrunber merged 1 commit into
che-incubator:mainfrom
rgrunber:custom-scheme

Conversation

@rgrunber

@rgrunber rgrunber commented Jun 16, 2026

Copy link
Copy Markdown
Collaborator
  • Some forked editor definitions may choose a non-'vscode://' URI
  • Improvements to OAuth host for the 'logged in' link
  • Remove unnecessary -p flag from 'cp' to reduce warnings

CC'ing @azatsarynnyy for a review as some of this code, particularly in sshd.init would be used by the Toolbox setup.

Summary by CodeRabbit

  • New Features

    • Added support for configurable URI schemes when generating Devspaces “Open in VS Code/Code-OSS” links (defaults to vscode).
    • Enhanced cluster host URL handling for the logged-in manual instructions by auto-discovering the correct host and using a fallback when discovery isn’t available.
  • Bug Fixes

    • Updated generated Devspaces Remote SSH connection links to consistently reflect the selected scheme and discovered host.
    • Improved SSH startup behavior by copying provisioned SSH data more reliably during initialization.

@tolusha

tolusha commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Hi! I'm che-ai-assistant — I help with your pull requests.

Available commands:

  • /che-ai-assistant generate-che-doc — Generate a documentation PR based on this PR's changes
  • /che-ai-assistant ok-pr-review — Run a comprehensive PR review (summary, code review, deep review, impact analysis)
  • /che-ai-assistant help — Show this help message

@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The changes introduce a configurable URI scheme for the SSH landing page's "Open in VS Code/Code-OSS" link. sshd.init now accepts a uri_scheme second argument and passes it to node server.js. server.js parses it (defaulting to vscode), adds an https import, and defers HTML generation until the new async getHostURL(callback) resolves. That helper replaces the old synchronous function and discovers the real cluster hostname by following a 302 redirect from /oauth/start, with a 10-second timeout and legacy fallback. The SSH URI href and displayed URI now use ${uriScheme}://, the manual oc login link switches to dynamically discovered ${hostURL}, and the inline openDevspacesURI call threads uriScheme as the first argument. The page-utils.js function gains a scheme parameter replacing the hardcoded vscode:// prefix. The SSH provisioning copy drops the -p attribute-preservation flag.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • che-incubator/che-code#704: Directly modifies the same openDevspacesURI function in page-utils.js and server.js to generate the vscode://redhat.devspaces-remote-ssh URI — this PR parameterizes the scheme that #704 hardcoded.

Suggested reviewers

  • azatsarynnyy
  • RomanNikitenko
  • vitaliy-guliy
🚥 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: adding support for custom URI schemes in connection URIs across the codebase.
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.
Rebase Rules For Upstream Changes ✅ Passed PR modifies only build/scripts/ files (page-utils.js, server.js, sshd.init); no files under code/ directory are changed, so rebase rules are not required.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@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: 3

🤖 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 `@build/scripts/code-sshd-page/server.js`:
- Around line 25-30: The uriScheme variable is assigned from unvalidated
command-line arguments and is subsequently rendered into HTML and JavaScript
contexts at multiple locations in the file. Add validation immediately after the
assignment of uriScheme from process.argv to restrict it to valid URI-scheme
characters only (alphanumeric characters, plus signs, periods, and hyphens per
RFC 3986). Implement this validation using a regular expression check (such as
/^[a-zA-Z][a-zA-Z0-9+.-]*$/) and either reject invalid schemes or fall back to
the default value, ensuring the malformed scheme cannot break out of HTML
attributes or JavaScript strings in the openDevspacesURI function call and href
attribute rendering.
- Around line 216-225: The timer in the getHostURL function is being armed
before environment variable validation and before proper request initialization,
causing the armed timer to fire after an early return, creating a temporal dead
zone where req is undefined and the callback gets called multiple times. Move
the setTimeout call to after the validation checks for consoleURL and
devspacesURL (after the early return condition), and only arm the timer when
both environment variables are defined and the request is properly initialized.
Additionally, ensure getFallbackURL is defined or imported before the getHostURL
function to avoid temporal dead zone issues with function references in the
timeout callback.
- Around line 242-250: Remove the `rejectUnauthorized: false` option from the
mod.get() call in the OAuth discovery request. This option disables TLS
certificate verification, creating a security vulnerability that allows
certificate spoofing. Instead, rely on the platform's proper CA configuration;
if a private CA is needed, deployers should configure NODE_EXTRA_CA_CERTS to add
it to Node's trust store.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c039b192-d4e3-4fbc-9315-a2707f88968d

📥 Commits

Reviewing files that changed from the base of the PR and between ff899a5 and 441f0a4.

📒 Files selected for processing (3)
  • build/scripts/code-sshd-page/page-utils.js
  • build/scripts/code-sshd-page/server.js
  • build/scripts/sshd.init

Comment thread build/scripts/code-sshd-page/server.js
Comment thread build/scripts/code-sshd-page/server.js Outdated
Comment thread build/scripts/code-sshd-page/server.js Outdated
@github-actions

github-actions Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Click here to review and test in web IDE: Contribute

@github-actions

Copy link
Copy Markdown
Contributor

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

@rgrunber

Copy link
Copy Markdown
Collaborator Author
======================
Summary:
  Total tests: 169 
  Successful: 161
  Failed: 8
  Elapsed time: 1h 30m 50s
======================

Failed tests:
  - Devfile 'https://registry.devfile.io/devfiles/nodejs' using image 'registry.access.redhat.com/ubi8-micro:latest'
  - Devfile 'https://registry.devfile.io/devfiles/nodejs' using image 'registry.access.redhat.com/ubi8/pause:latest'
  - Devfile 'https://registry.devfile.io/devfiles/nodejs' using image 'registry.access.redhat.com/ubi9-micro:9.6'
  - Devfile 'https://registry.devfile.io/devfiles/nodejs' using image 'registry.access.redhat.com/ubi9/ubi-stig:9.6'
  - Devfile 'https://registry.devfile.io/devfiles/nodejs' using image 'registry.access.redhat.com/ubi9-micro:9.7'
  - Devfile 'https://registry.devfile.io/devfiles/nodejs' using image 'registry.access.redhat.com/ubi9/ubi-stig:9.7'
  - Devfile 'https://registry.devfile.io/devfiles/nodejs' using image 'registry.access.redhat.com/ubi10/ubi-micro:10.0'
  - Devfile 'https://registry.devfile.io/devfiles/nodejs' using image 'registry.access.redhat.com/ubi10/ubi-micro:10.1'

@rgrunber

Copy link
Copy Markdown
Collaborator Author

I intend to merge this soon.

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

🤖 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 `@build/scripts/code-sshd-page/server.js`:
- Around line 239-249: The OAuth discovery response body is never consumed,
which leaves sockets occupied indefinitely in Node.js 22. In the mod.get
callback function that handles the OAuth discovery response, after checking the
response headers and processing the redirect location, call res.resume() on the
response object to drain the body. This allows the socket to be properly
released back to the connection pool and should be called in both the successful
response branch (when statusCode is 302) and the fallback branch to ensure the
body is always consumed regardless of the response status.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6596b79c-2fa8-4601-b35d-3e2aa8d28973

📥 Commits

Reviewing files that changed from the base of the PR and between 441f0a4 and 81c4743.

📒 Files selected for processing (3)
  • build/scripts/code-sshd-page/page-utils.js
  • build/scripts/code-sshd-page/server.js
  • build/scripts/sshd.init
🚧 Files skipped from review as they are similar to previous changes (2)
  • build/scripts/code-sshd-page/page-utils.js
  • build/scripts/sshd.init

Comment thread build/scripts/code-sshd-page/server.js
- Some forked editor definitions may choose a non-'vscode://' URI
- Improvements to OAuth host for the 'logged in' link
- Remove unnecessary -p flag from 'cp' to reduce warnings

Signed-off-by: Roland Grunberg <rgrunber@redhat.com>

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

🤖 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 `@build/scripts/code-sshd-page/server.js`:
- Line 224: Wrap both `new URL()` calls (at line 224 with `devspacesURL` and at
line 243 with the OAuth endpoint location) in try-catch blocks to prevent the
server from crashing on malformed URLs. In each catch block, log the error with
appropriate context and either exit the process gracefully or handle the error
appropriately by providing fallback values or returning an error response. This
ensures that malformed input from `CHE_DASHBOARD_URL` environment variable or
invalid redirect locations from OAuth responses will not cause unhandled
exceptions.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 665f2795-b75e-48e6-bfbd-723c40e3ebf8

📥 Commits

Reviewing files that changed from the base of the PR and between 81c4743 and 69fd7a8.

📒 Files selected for processing (3)
  • build/scripts/code-sshd-page/page-utils.js
  • build/scripts/code-sshd-page/server.js
  • build/scripts/sshd.init
🚧 Files skipped from review as they are similar to previous changes (2)
  • build/scripts/code-sshd-page/page-utils.js
  • build/scripts/sshd.init

Comment thread build/scripts/code-sshd-page/server.js
@github-actions

Copy link
Copy Markdown
Contributor

@rgrunber
rgrunber merged commit 4e7d166 into che-incubator:main Jun 22, 2026
22 of 23 checks passed
@rgrunber
rgrunber deleted the custom-scheme branch June 22, 2026 20:04
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