Skip to content

fix: skip starlette check when server version is hidden #696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 4, 2025

Conversation

christierney
Copy link
Collaborator

Intent

If Connect's server version is hidden, skip the starlette dependency check and log a warning.

Fixes #695

Type of Change

  • Bug Fix
  • New Feature
  • Breaking Change

Approach

Only call fix_starlette_requirements if we have a non-empty Connect version string. Otherwise, log a warning, which will hopefully provide a helpful breadcrumb if users on a pre-2024.01.0 Connect see starlette errors.

Automated Tests

Opted not to add a new test for such a small change.

Directions for Reviewers

I manually reproduced the bug by running Connect locally with [Server] HideVersion = true:

logs of failed deploy
rsconnect-python on  chris-empty-version [?] via 🐍 v3.13.3 (.venv) on ☁️  (us-east-1)
❯ rsconnect deploy shiny top-5-income-share-shiny
    Warning: the existing manifest.json file will not be used or considered.
    Warning: Python version constraint missing from pyproject.toml, setup.cfg or .python-version
             Connect will guess the version to use based on local environment.
             Consider specifying a Python version constraint.
Traceback (most recent call last):
  File "/Users/chris/dev/posit-dev/rsconnect-python/rsconnect/main.py", line 118, in wrapper
    result = func(*args, **kwargs)
  File "/Users/chris/dev/posit-dev/rsconnect-python/.venv/lib/python3.13/site-packages/click/decorators.py", line 34, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/Users/chris/dev/posit-dev/rsconnect-python/rsconnect/main.py", line 1698, in deploy_app
    environment = fix_starlette_requirements(
        environment=environment,
        app_mode=app_mode,
        connect_version_string=ce.client.server_settings()["version"],
    )
  File "/Users/chris/dev/posit-dev/rsconnect-python/rsconnect/utils_package.py", line 220, in fix_starlette_requirements
    if not (app_mode == AppModes.PYTHON_SHINY and compare_semvers(connect_version_string, "2024.01.0") == -1):
                                                  ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/chris/dev/posit-dev/rsconnect-python/rsconnect/utils_package.py", line 58, in compare_semvers
    return semver.VersionInfo.parse(version1).compare(version2)  # type: ignore
           ~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/Users/chris/dev/posit-dev/rsconnect-python/.venv/lib/python3.13/site-packages/semver/version.py", line 644, in parse
    raise ValueError(f"{version} is not valid SemVer string")
ValueError:  is not valid SemVer string
Internal error:  is not valid SemVer string

With this fix, the deployment succeeds:

logs of successful deploy
rsconnect-python on  chris-empty-version [!?] via 🐍 v3.11.12 (.venv) on ☁️  (us-east-1) took 11s
❯ rsconnect deploy shiny top-5-income-share-shiny
    Warning: the existing manifest.json file will not be used or considered.
    Warning: Python version constraint missing from pyproject.toml, setup.cfg or .python-version
             Connect will guess the version to use based on local environment.
             Consider specifying a Python version constraint.
    Warning: Connect server version is hidden. Skipping starlette requirements check.
Validating server...    [OK]
Validating app mode...  [OK]
Making bundle ...       [OK]
Deploying bundle ...    [OK]
Saving deployed information...  [OK]
Building Python Shiny application...
Bundle created with Python version 3.11.12 is compatible with environment Local with Python version 3.11.3 from /opt/python/3.11.3/bin/python3.11
Bundle requested Python version 3.11.12; using /opt/python/3.11.3/bin/python3.11 from Local which has version 3.11.3
2025/07/30 19:13:50.780421842 [connect-session] Content GUID: 0de661cc-bbf7-44e1-86ff-7e975c339f6b
2025/07/30 19:13:50.781082509 [connect-session] Content ID: 2
2025/07/30 19:13:50.781133426 [connect-session] Bundle ID: 6
2025/07/30 19:13:50.781191717 [connect-session] Job Key: Rfjtobm8E2dkAm6u
2025/07/30 19:13:50.781255926 [connect-session] WARNING: Publishing with rsconnect-python or Publisher, upgrade for the generated manifest.json to follow version constraints best practices.
2025/07/30 19:13:50.781300926 [connect-session] For more details on version matching, see https://docs.posit.co/connect/admin/python/#python-version-matching
Determining session server location ...
Connecting to session server http://127.0.0.1:43671 ...
Connected to session server http://127.0.0.1:43671
2025/07/30 19:13:50.941386051 Running on host: connect
...
Deployment completed successfully.
         Dashboard content URL: http://localhost:3939/connect/#/apps/0de661cc-bbf7-44e1-86ff-7e975c339f6b/access
         Direct content URL: http://localhost:3939/content/0de661cc-bbf7-44e1-86ff-7e975c339f6b/
Verifying deployed content...   [OK]

Checklist

  • I have updated CHANGELOG.md to cover notable changes.
  • I have updated all related GitHub issues to reflect their current state.

@christierney christierney requested review from amol- and lucasrod16 July 30, 2025 19:31
Copy link

github-actions bot commented Jul 30, 2025

PR Preview Action v1.6.2
Preview removed because the pull request was closed.
2025-08-04 21:51 UTC

Copy link

github-actions bot commented Jul 30, 2025

☂️ Python Coverage

current status: ✅

Overall Coverage

Lines Covered Coverage Threshold Status
5146 3995 78% 0% 🟢

New Files

No new covered files...

Modified Files

File Coverage Status
rsconnect/main.py 69% 🟢
TOTAL 69% 🟢

updated for commit: 30196b5 by action🐍

@nealrichardson
Copy link
Contributor

CI failures are probably #694

@christierney
Copy link
Collaborator Author

CI failures are probably #694

Thank you, I was trying to figure out how my change could possibly have caused this!

# 2024.01.1 or later, this can be removed. Requires access to the
# Connect server version, which may be hidden.
connect_version_string = ce.client.server_settings()["version"]
if connect_version_string != "":
Copy link
Collaborator

@amol- amol- Jul 31, 2025

Choose a reason for hiding this comment

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

I would make this one a if not connect_version_string, I perceive it as slightly more robust as it will cover both "" and null.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it should be if connect_version_string: (no not), right?

)
# 2024.01.1 or later, this can be removed. Requires access to the
# Connect server version, which may be hidden.
connect_version_string = ce.client.server_settings()["version"]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this maybe be .get("version")? Or do we feel safe in taking for granted the version field will alwasy be there even when hidden?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It will be there unless we make a breaking change in Connect, but at the same time I see no reason not to use the more robust code here.

@christierney christierney force-pushed the chris-empty-version branch from 7696d23 to 4868772 Compare July 31, 2025 14:55
@christierney christierney requested a review from amol- July 31, 2025 14:55
@nealrichardson
Copy link
Contributor

@christierney I think you can rebase again now and CI should be fixed

@christierney christierney merged commit 057b923 into main Aug 4, 2025
16 checks passed
@christierney christierney deleted the chris-empty-version branch August 4, 2025 21:50
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.

python-shiny deploy fails when Connect version is unavailable
4 participants