[GH-ISSUE #4395] [TUI] running_launches(): prof is read outside the try that binds it — traceback, or the wrong launch's config #1954

Closed
opened 2026-11-04 01:55:34 +07:00 by bsakaguchi · 2 comments
Owner

Originally created by @TheHubUser4860938 on GitHub (Oct 28, 2026).
Original GitHub issue: https://github.com/Niko1221/Strata/issues/4395

Problem: in strata_cli/launch/cmd.py:612-619, prof is bound inside the try and the except sets only ov = {} — but line 620 reads prof.get("source_config") AFTER the try, unguarded. If profiles.load() raises for a profile whose RUNTIME state is ready/starting (status comes from the runtime state file, independent of the profile file): the first such row raises UnboundLocalError — a NameError, not a ValueError — which escapes both run_launch's handlers and _run's (ValueError/BrokenPipeError/OSError/ClientError/KeyboardInterrupt) → raw traceback from strata launch --status, --show-key, connect. On a LATER bad row, prof still holds the PREVIOUS profile's dict, so the row reports another launch's source_config — and launch_info() reads the API key from that wrong config.

Environment:
Strata Version: 0.2.7 (source checkout at tag v0.2.7, commit 5e8a4cca; the file discussed is byte-identical to the tag)
OS: Linux x86-64
Runtime: Python 3.14
Reported from the Strata-Mnemosyne fork's merged tree; the offending code is upstream's own.

Reproduce (measured): with runtime.status stubbed to ready and exactly one profile present whose overrides are invalid (e.g. overrides.port as a string — profiles are owner-editable by design, and validate_overrides demands int): UnboundLocalError: cannot access local variable 'prof' where it is not associated with a value.

Expected: one damaged profile costs at most that row (or a clean one-line error).
Actual: traceback, or another launch's config reported for this row.

Reproduction status: crash measured at function level; the mis-attribution case read from the code. An AST sweep of strata_cli/ + strata_control/ (~34k lines) for this try-binding pattern found this as the only hit in scope.

Originally created by @TheHubUser4860938 on GitHub (Oct 28, 2026). Original GitHub issue: https://github.com/Niko1221/Strata/issues/4395 Problem: in strata_cli/launch/cmd.py:612-619, `prof` is bound inside the try and the except sets only `ov = {}` — but line 620 reads `prof.get("source_config")` AFTER the try, unguarded. If `profiles.load()` raises for a profile whose RUNTIME state is ready/starting (status comes from the runtime state file, independent of the profile file): the first such row raises UnboundLocalError — a NameError, not a ValueError — which escapes both `run_launch`'s handlers and `_run`'s (ValueError/BrokenPipeError/OSError/ClientError/KeyboardInterrupt) → raw traceback from `strata launch --status`, `--show-key`, `connect`. On a LATER bad row, `prof` still holds the PREVIOUS profile's dict, so the row reports another launch's `source_config` — and launch_info() reads the API key from that wrong config. Environment: **Strata Version:** 0.2.7 (source checkout at tag v0.2.7, commit 5e8a4cca; the file discussed is byte-identical to the tag) **OS:** Linux x86-64 **Runtime:** Python 3.14 Reported from the Strata-Mnemosyne fork's merged tree; the offending code is upstream's own. Reproduce (measured): with `runtime.status` stubbed to ready and exactly one profile present whose overrides are invalid (e.g. `overrides.port` as a string — profiles are owner-editable by design, and validate_overrides demands int): `UnboundLocalError: cannot access local variable 'prof' where it is not associated with a value`. Expected: one damaged profile costs at most that row (or a clean one-line error). Actual: traceback, or another launch's config reported for this row. Reproduction status: crash measured at function level; the mis-attribution case read from the code. An AST sweep of strata_cli/ + strata_control/ (~34k lines) for this try-binding pattern found this as the only hit in scope.
Author
Owner

@Nyarlathoteppppp commented on GitHub (Oct 29, 2026):

I have a fix with a regression test that fails before and passes after; opening a PR shortly.

<!-- gh-comment-id:6486293455 --> @Nyarlathoteppppp commented on GitHub (Oct 29, 2026): I have a fix with a regression test that fails before and passes after; opening a PR shortly.
Author
Owner

@Niko1221 commented on GitHub (Nov 5, 2026):

Hello TheHubUser4860938,

Thank you for tracing this to the line. In Strata 0.2.11 a damaged launch profile gets its own defaults when launches are listed, and never shows the previous row's config or port. We reproduced it on the old code with real temporary profiles in both orders and the new tests pass. If you still see another launch's settings on a damaged profile, please send the output of strata launch --status with the profile names changed if needed.

The Strata project

<!-- gh-comment-id:6658432128 --> @Niko1221 commented on GitHub (Nov 5, 2026): Hello TheHubUser4860938, Thank you for tracing this to the line. In Strata 0.2.11 a damaged launch profile gets its own defaults when launches are listed, and never shows the previous row's config or port. We reproduced it on the old code with real temporary profiles in both orders and the new tests pass. If you still see another launch's settings on a damaged profile, please send the output of `strata launch --status` with the profile names changed if needed. The Strata project
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#1954
No description provided.