Skip to content

Commit e5029ca

Browse files
Fix: Disable Showing (Secret) Locals on Rich Tracebacks (#42)
* Disable Show Locals on Rich Tracebacks * Add Warning about Potential Exposure of Secrets when SML_DEBUG is Enabled
1 parent c93b67c commit e5029ca

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,18 @@ sml advanced \
159159

160160
## Development
161161

162+
### Debugging
163+
164+
Set `SML_DEBUG=1` to include local variables in crash tracebacks:
165+
166+
```bash
167+
export SML_DEBUG=1
168+
```
169+
170+
By default, local variables are hidden from crash reports.
171+
172+
> **Warning:** `SML_DEBUG=1` may expose secrets (such as your CSCS API key) in crash output. Do not share terminal output captured with this flag enabled.
173+
162174
### Setting Up Development Environment
163175

164176
```bash

src/swiss_ai_model_launch/cli/display/live.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
1+
import os
12
from collections.abc import Coroutine
23
from typing import Any
34

5+
import rich
6+
from rich.segment import Segments
47
from rich.table import Table
8+
from rich.traceback import Traceback
59
from textual.app import App, ComposeResult
610
from textual.binding import Binding
711
from textual.widgets import Footer, Header, Label, RichLog, TabbedContent, TabPane
@@ -85,6 +89,19 @@ def action_quit_resume(self) -> None:
8589
def action_quit_kill(self) -> None:
8690
self.exit(True)
8791

92+
def _fatal_error(self) -> None:
93+
show_locals = os.environ.get("SML_DEBUG", "").lower() in ("1", "true", "yes")
94+
self.bell()
95+
self._exit_renderables.append(
96+
Segments(
97+
self.console.render(
98+
Traceback(show_locals=show_locals, width=None, suppress=[rich]),
99+
self.console.options,
100+
)
101+
)
102+
)
103+
self._close_messages_no_wait()
104+
88105
def _render_status(self) -> Table:
89106
s = self._state
90107
job_status = (

0 commit comments

Comments
 (0)