[PR #4563] [TUI] kept_key: skip unreadable profiles instead of minting a new API key #5087

Open
opened 2026-11-07 16:32:36 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4563
Author: @Nyarlathoteppppp
Created: 10/29/2026
Status: 🔄 Open

Base: main ← Head: fix/4396-kept-key-bad-row


📝 Commits (1)

  • 5f202d7 launch: one unreadable profile no longer hides the kept API key from the others (#4396)

📊 Changes

2 files changed (+14 additions, -2 deletions)

View changed files

📝 strata_cli/launch/access.py (+5 -2)
📝 tests/terminal/test_tui_stress.py (+9 -0)

📄 Description

Problem and result

kept_key() in strata_cli/launch/access.py falls back to the newest launch profile that holds a key. profiles.list_profiles() returns {"id", "error"} for a profile it cannot read, and the loop indexes row["source_config"]. The KeyError escapes to the outer except Exception: return None, so one unreadable launch profile makes the whole lookup return None and strata launch mints a new API key, even when another launch profile has one.

After the change, rows without source_config are skipped and the other profiles are still searched.

Fixes #4396. Focused fix, no scope change.

Approach

Read row.get("source_config") once and continue when it is missing. The outer guard stays, so the lookup still never blocks a launch.

Validation

Passed:

  • python -m pytest tests/terminal/test_tui_stress.py -k KeptKey: the new test (damaged row before and after a valid launch row, as subtests) fails on 46c152a (returns None) and passes with the fix; whole file 12 passed.
  • python -m pytest tests/terminal/test_launch.py tests/terminal/test_launch_dsv41.py tests/terminal/test_tui_stress.py tests/terminal/test_tui_stress_launch.py tests/terminal/test_dsv41_tui_items.py tests/terminal/test_dsv41_engine.py tests/terminal/test_launch_show_key_setup.py: 203 passed, 5 failed. The same 5 fail on 46c152a without this change (202 passed).
  • Environment: macOS 26 (Darwin 25.5) arm64, Apple M1 Pro, Python 3.14.7 venv with requirements.txt + pytest, base 46c152a.

Failed:
none observed beyond the 5 pre-existing failures above.

Not run:
full test suite, Windows/Linux, a real launch with an unreadable profile file.

Limits

none known.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/4563 **Author:** [@Nyarlathoteppppp](https://github.com/Nyarlathoteppppp) **Created:** 10/29/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/4396-kept-key-bad-row` --- ### 📝 Commits (1) - [`5f202d7`](https://github.com/Niko1221/Strata/commit/5f202d7b5e87f1b5ee1989dcae362b1255070413) launch: one unreadable profile no longer hides the kept API key from the others (#4396) ### 📊 Changes **2 files changed** (+14 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `strata_cli/launch/access.py` (+5 -2) 📝 `tests/terminal/test_tui_stress.py` (+9 -0) </details> ### 📄 Description ## Problem and result `kept_key()` in `strata_cli/launch/access.py` falls back to the newest launch profile that holds a key. `profiles.list_profiles()` returns `{"id", "error"}` for a profile it cannot read, and the loop indexes `row["source_config"]`. The `KeyError` escapes to the outer `except Exception: return None`, so one unreadable launch profile makes the whole lookup return `None` and `strata launch` mints a new API key, even when another launch profile has one. After the change, rows without `source_config` are skipped and the other profiles are still searched. ## Related discussion Fixes #4396. Focused fix, no scope change. ## Approach Read `row.get("source_config")` once and `continue` when it is missing. The outer guard stays, so the lookup still never blocks a launch. ## Validation **Passed:** - `python -m pytest tests/terminal/test_tui_stress.py -k KeptKey`: the new test (damaged row before and after a valid launch row, as subtests) fails on `46c152a` (returns `None`) and passes with the fix; whole file 12 passed. - `python -m pytest tests/terminal/test_launch.py tests/terminal/test_launch_dsv41.py tests/terminal/test_tui_stress.py tests/terminal/test_tui_stress_launch.py tests/terminal/test_dsv41_tui_items.py tests/terminal/test_dsv41_engine.py tests/terminal/test_launch_show_key_setup.py`: 203 passed, 5 failed. The same 5 fail on `46c152a` without this change (202 passed). - Environment: macOS 26 (Darwin 25.5) arm64, Apple M1 Pro, Python 3.14.7 venv with requirements.txt + pytest, base `46c152a`. **Failed:** none observed beyond the 5 pre-existing failures above. **Not run:** full test suite, Windows/Linux, a real launch with an unreadable profile file. ## Limits none known. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#5087
No description provided.