Skip to content

studio: explicit Cloudflare tunnel notice and public-exposure warning at startup - #6515

Merged
wasimysaid merged 14 commits into
mainfrom
studio-cloudflare-notice
Jun 30, 2026
Merged

wasimysaid merged 14 commits into
mainfrom
studio-cloudflare-notice

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Problem

On a wildcard bind (-H 0.0.0.0), Studio starts a Cloudflare quick tunnel by default, but the startup output only printed a line when a URL was present. A user running on a local network behind a firewall had no clear signal that Studio had become reachable from the public internet through a trycloudflare.com URL.

Change

  • _print_cloudflare_line() now always prints the tunnel state at startup:
    • ON: the public URL plus a warning that anyone with the link can reach this Studio, and how to disable it with --no-cloudflare.
    • OFF: "local network only" when the tunnel is disabled on a wildcard bind.
    • FAILED: a one line notice when a requested tunnel did not come up.
  • Clarified the --cloudflare help text in run.py argparse and both unsloth_cli typer options to state it defaults on and exposes Studio publicly.
  • No default change: the tunnel still defaults on.

Validation

  • Extended test_cloudflare_tunnel.py and test_secure_tunnel_gate.py to cover the ON / OFF / FAILED strings and the secure-mode path.
  • Live: launched with -H 0.0.0.0 --no-cloudflare and confirmed the disabled notice.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request improves the startup banner to explicitly report the status of the Cloudflare tunnel (ON, OFF, or FAILED) and warns users about public exposure when the tunnel is active (unless running in secure mode). It also updates the CLI help text and adds corresponding unit tests. The reviewer noted that the run command in unsloth_cli/commands/studio.py bypasses this new logic because its custom startup banner does not call _print_cloudflare_line(), leading to inconsistent behavior and missing warnings.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread unsloth_cli/commands/studio.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b33083cc7b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread studio/backend/run.py Resolved
Comment thread unsloth_cli/commands/studio.py Resolved
@danielhanchen
danielhanchen force-pushed the studio-cloudflare-notice branch 2 times, most recently from 1fe1d9a to d52710c Compare June 20, 2026 13:54

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d52710ca47

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread studio/backend/run.py Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

…re on startup

The startup banner only printed a line when a tunnel URL was up, so a plain
`unsloth studio -H 0.0.0.0` launch silently created a public trycloudflare.com
URL with no indication that Studio had become reachable from the internet. The
only hint at the tunnel was the CLI help, shown when an invalid command was typed.

Make the banner always state the tunnel state for wildcard binds:
- ON: the public URL plus a warning that anyone with it can reach Studio from
  outside the network, and that --no-cloudflare keeps it local-only.
- FAILED: requested but did not start (local network only).
- OFF: --no-cloudflare was passed (local network only).
Secure mode keeps its existing wording (the authenticated tunnel is intended and
--no-cloudflare is not valid there). Clarify the --cloudflare help text in both
the argparse and typer definitions. Default behavior is unchanged.

Also surface the state on the `unsloth studio run` banner, which runs the server
with silent=True and prints its own banner: it now calls _print_cloudflare_line
too, so the ON/OFF/FAILED notice and public-exposure warning are no longer
skipped on that path (previously it only echoed the URL when a tunnel was up).

For the OFF and FAILED notices, do not claim "local network only" when the
reachability probe just confirmed the raw port is reachable from the public
internet: --no-cloudflare and a failed tunnel disable only the Cloudflare link,
not the wildcard bind, so the message is reworded to flag the public raw port.
@danielhanchen
danielhanchen force-pushed the studio-cloudflare-notice branch from d85eadf to ea1bebe Compare June 22, 2026 05:27
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 88b3eca325

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread unsloth_cli/commands/studio.py Resolved
Comment thread unsloth_cli/commands/studio.py Resolved
Comment thread studio/backend/run.py Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

@wasimysaid

Copy link
Copy Markdown
Collaborator

Pushed f508ce5d7 with the Cloudflare banner followups.

Summary:

  • Removed local-only claims when the raw wildcard port is public or reachability is unknown.
  • Updated unsloth studio run to run the reachability check before printing tunnel state, and only print tunnel state for wildcard binds.
  • Updated the Cloudflare banner tests, added an AST guard for the run banner path, and fixed the existing startup banner test stub.

Validation:

  • python -m pytest studio/backend/tests/test_cloudflare_tunnel.py studio/backend/tests/test_secure_tunnel_gate.py
  • python -m pytest unsloth_cli/tests/test_studio_cloudflare_flag.py unsloth_cli/tests/test_studio_run_parallel_flag.py
  • python -m pytest tests/studio/install/test_selection_logic.py
  • python -m compileall -q studio/backend/run.py unsloth_cli/commands/studio.py studio/backend/tests/test_cloudflare_tunnel.py studio/backend/tests/test_secure_tunnel_gate.py unsloth_cli/tests/test_studio_cloudflare_flag.py tests/studio/install/test_selection_logic.py
  • git diff --check
  • Targeted local repro assertion for the previous bad Cloudflare banner strings

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@danielhanchen

Copy link
Copy Markdown
Member Author

/gemini review

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request extends Cloudflare tunnel support to wildcard binds (including :: in addition to 0.0.0.0) and enhances the startup banner to display detailed, colorized warnings about public reachability and tunnel status. It also updates corresponding CLI help messages and expands the test suite. Feedback on these changes suggests highlighting a security warning in run.py with the warn style and dynamically including the host variable. Additionally, the reviewer recommends refactoring fragile tests in test_cloudflare_tunnel.py and test_studio_cloudflare_flag.py that rely on literal string matching and AST parsing of source code to use more robust testing patterns.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread studio/backend/run.py Resolved

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request updates the Cloudflare tunnel startup logic to support IPv6 wildcard binds ("::") alongside "0.0.0.0", refactors the startup banner output to clearly communicate the tunnel's status and security implications, and adds corresponding unit tests. The reviewer feedback suggests improving the security warning when the tunnel is disabled by applying the warning style and dynamically resolving the loopback address, as well as centralizing the external host check into a helper function rather than hardcoding specific wildcard IP checks.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread studio/backend/run.py Resolved
Comment thread unsloth_cli/commands/studio.py Resolved

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 09fb7c6619

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread studio/backend/run.py Resolved
Comment thread studio/backend/run.py Resolved
Comment thread studio/backend/run.py Resolved
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.

@wasimysaid

Copy link
Copy Markdown
Collaborator

Pushed e73bb7170 with the review followups.

Summary:

  • Cloudflare status now prints an explicit OFF state when the flag is enabled but no tunnel starts for the current mode.
  • Unknown-reachability warnings now use the warning style and the correct loopback bind (127.0.0.1 or ::1).
  • -H :: now uses the same wildcard display-host resolution as 0.0.0.0, and URL hosts are bracketed when needed.
  • Private/LAN reachability now records _public_reachable=False before returning.
  • Removed the fragile source-string test and replaced the CLI AST check with behavioral helper coverage.

Validation:

  • ~/.unsloth/studio/unsloth_studio/bin/python -m py_compile studio/backend/run.py unsloth_cli/commands/studio.py studio/backend/tests/test_cloudflare_tunnel.py unsloth_cli/tests/test_studio_cloudflare_flag.py
  • ~/.unsloth/studio/unsloth_studio/bin/python -m pytest studio/backend/tests/test_cloudflare_tunnel.py studio/backend/tests/test_secure_tunnel_gate.py
  • ~/.unsloth/studio/unsloth_studio/bin/python -m pytest unsloth_cli/tests/test_studio_cloudflare_flag.py unsloth_cli/tests/test_studio_run_parallel_flag.py
  • ~/.unsloth/studio/unsloth_studio/bin/python -m pytest tests/studio/install/test_selection_logic.py
  • git diff --check

@wasimysaid

Copy link
Copy Markdown
Collaborator

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: 9782072f41

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@wasimysaid
wasimysaid merged commit b72a8c4 into main Jun 30, 2026
49 of 50 checks passed
@wasimysaid
wasimysaid deleted the studio-cloudflare-notice branch June 30, 2026 15:47
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