-
Notifications
You must be signed in to change notification settings - Fork 2
Let Tower SDK use the local session when running in --local mode
#55
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
Let Tower SDK use the local session when running in --local mode
#55
Conversation
This PR allows users to pass their current auth context into locally-ran apps. This means that you'll authenticate with the server using your current session, etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enables the Tower SDK and CLI to propagate the current session JWT when running in --local mode and improves error handling for missing apps.
- Extend Python
TowerContextand_env_clientto read and useTOWER_JWTfor auth. - Introduce
AppNotFoundErrorin Python and add a test for 404 responses inrun_app. - Update Rust CLI
do_run_localto injectTOWER_JWTinto subprocess environment.
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/tower/test_client.py | Add test_raising_an_error_for_a_not_found_app to verify 404 |
| src/tower/exceptions.py | Introduce AppNotFoundError for missing apps |
| src/tower/_context.py | Add jwt field and defaults for TOWER_URL and TOWER_ENVIRONMENT |
| src/tower/_client.py | Catch 404 status and raise AppNotFoundError; support JWT auth |
| crates/tower-cmd/src/run.rs | Pass environment and TOWER_JWT into local runs |
Comments suppressed due to low confidence (2)
src/tower/_client.py:6
- The docstring for
run_appshould be updated to document the newAppNotFoundErrorunder theRaises:section so users know it can be thrown on a 404 response.
from ._context import TowerContext
tests/tower/test_client.py:335
- [nitpick] The variable
towerhere refers to a client fixture; consider renaming it toclientorapi_clientfor clarity.
tower = mock_api_config
| raise RuntimeError(f"Error running app: {output.title}") | ||
| else: | ||
| return output.run | ||
| except UnexpectedStatus as e: |
Copilot
AI
Jun 23, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently this except block only handles 404 and otherwise swallows all other status codes, causing the function to return None. Consider re-raising non-404 statuses (e.g. raise) or mapping them to other exceptions to avoid silent failures.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
konstantinoscs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Took a quick look but anyway approving this as per the CTOs edict
* chore: Upgrade Tower API version * Let Tower SDK use the local session when running in `--local` mode (#55) * feat: Pass local context into local runs This PR allows users to pass their current auth context into locally-ran apps. This means that you'll authenticate with the server using your current session, etc. * chore: Raise an AppNotFoundError when we fail to find an app * Update crates/tower-cmd/src/run.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update crates/tower-cmd/src/run.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: Add test for other error types --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: Bump version to v0.3.19 --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* chore: Upgrade Tower API version * Let Tower SDK use the local session when running in `--local` mode (#55) * feat: Pass local context into local runs This PR allows users to pass their current auth context into locally-ran apps. This means that you'll authenticate with the server using your current session, etc. * chore: Raise an AppNotFoundError when we fail to find an app * Update crates/tower-cmd/src/run.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update crates/tower-cmd/src/run.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: Add test for other error types --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: Bump version to v0.3.19 --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* chore: Upgrade Tower API version * Let Tower SDK use the local session when running in `--local` mode (#55) * feat: Pass local context into local runs This PR allows users to pass their current auth context into locally-ran apps. This means that you'll authenticate with the server using your current session, etc. * chore: Raise an AppNotFoundError when we fail to find an app * Update crates/tower-cmd/src/run.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update crates/tower-cmd/src/run.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: Add test for other error types --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: Bump version to v0.3.19 --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* chore: Upgrade Tower API version * Let Tower SDK use the local session when running in `--local` mode (#55) * feat: Pass local context into local runs This PR allows users to pass their current auth context into locally-ran apps. This means that you'll authenticate with the server using your current session, etc. * chore: Raise an AppNotFoundError when we fail to find an app * Update crates/tower-cmd/src/run.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update crates/tower-cmd/src/run.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: Add test for other error types --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: Bump version to v0.3.19 * feat: move tower-cli to rustls * fixing tests after api changes * chore: Bump version to v0.3.20 * Release v0.3.19 (#56) * chore: Upgrade Tower API version * Let Tower SDK use the local session when running in `--local` mode (#55) * feat: Pass local context into local runs This PR allows users to pass their current auth context into locally-ran apps. This means that you'll authenticate with the server using your current session, etc. * chore: Raise an AppNotFoundError when we fail to find an app * Update crates/tower-cmd/src/run.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update crates/tower-cmd/src/run.rs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: Add test for other error types --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: Bump version to v0.3.19 --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Add flake.nix file to support nix ecosystem * Extract out metadata and common build inputs * Add to README and rename tower-cli target to simply tower * Use the version.txt file instead of hardcoding version in nix flake * chore: Fix broken API integration --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Konstantinos Stefanidis Vozikis <kons.ste@gmail.com> Co-authored-by: Ben Lovell <ben.j.lovell@gmail.com>
This PR adds the ability for Tower CLI to pass along it's current session to running Python apps when running in
--localmode. An alternative implementation would be to read the session data eagerly; however, this is a bit more specific.We also introduce a test for cases where an app can't be found in Tower.